Email Function in PHP

Hi,
I’m trying to send an email from the my code. The email part of it works fine.
I want all the details of the order to be sent as email as well. How do I do it? I tried putting a while loop in the body of the email but it does not work.

This is my select statement.
$result = mysql_query(“SELECT * FROM orderdet a WHERE a.orderId =$orderno”);

I need all the details to be displayed in the email.

here is the code. I took out the while loop

 
$to = "a@yahoo.com";
$from = "a@p.com";
$title = "Your Order Details";
$body = <<< emailbody
Dear Customer,
This email confirms your purchase of a our products.
Here are the order details.
Order Number: $orderno
Name : $firstname $lastname
email: $email
Total: $total
Your Order will be shipped to you.
Thank you,
The support staff
emailbody;
$success = mail($to,$title,$body,"From:$from
Reply-To:a@yahoo.com");