Making mail form that will handle more than one SQL table?
Posted: Wed Sep 26, 2007 7:55 am
Hi Im trying to have multiple database tables pulled and made into blocks of information to send by email.
sorta like a receipt or invoice that lists each. I can get it to work when i echo a page out.
But not sure how to do this for mail.
Heres what i have
and then i add this static section to the top of that
See how the variable = $order_description
is only going to overwrite itself leaving only the last block of data displayed. How can i get it to display all in an email?
I can get that same script to work if i just echo them onto a webpage , but not with this because of the single variable used.
Any ideas?
Thank You!
sorta like a receipt or invoice that lists each. I can get it to work when i echo a page out.
But not sure how to do this for mail.
Heres what i have
Code: Select all
($user_row['user_id'] is set above here)
$query= "SELECT * FROM user_cart_records WHERE user_id = " . $user_row['user_id'] ;
$result=mysql_query ($query); // Run the query.
$num=mysql_num_rows($result);
// Fetch and print all the records.
while ($row=mysql_fetch_array($result, MYSQL_ASSOC)) {
$user_id = $_SESSION['user_id'];
$product_name = $row['product_name'];
$product_id = $row['product_id'];
$quantity = $row['quantity'];
$shipping_type = $row['shipping_type'];
$shipping_price = $row['shipping_price'];
$subtotal = $row['subtotal'];
$total = $row['total'];
$total_display1 = number_format($total,2);
$date = $row['date'];
$today = date("F j, Y, g:i a");
$ip = $_SERVER['REMOTE_ADDR'];
$totalSum+=$total;
$grand_total = number_format($totalSum,2,'.',',');
// MAKE DYNAMIC MAIL MESSAGE SECTION - You've GOT MAIL -- YAY.
$order_description =
"**************** ITEM **************************" . "\r\n" .
"------------------------------------------------" . "\r\n" .
" Order Details" . "\r\n" .
"------------------------------------------------" . "\r\n" .
"Product Name: " . $product_name . "\r\n" .
"Product ID: " . $product_id . "\r\n" .
"Quantity: " . $quantity . "\r\n" .
"Subtotal: " . $subtotal . "\r\n" .
"Shipping Type: " . $shipping_type . "\r\n" .
"Shipping Charges: " . $shipping_price . "\r\n" .
" ++ TOTAL ++ : " . $total . "\r\n" . "\r\n" .
"*************************************************************************" . "\r\n" . "\r\n" .
// END MAIL - YAY
}
}
?>and then i add this static section to the top of that
Code: Select all
<?php
//Calculate Grand Total of all above dynamic product blocks.
$grand_total_mail = "Grand Total_____________" . $grand_total;
// User info section of mail.
$message_userinfo = "all the user info mail form here ..blah blah "
$to = 'blah@somethin.com';
$from = 'test_blah@somethin.com';
$subject = 'New Order' ;
$message = $message_userinfo . $order_description . $grand_total_mail;
// Send the mail //
$ok1 = @mail($to, $subject, $message);
?>See how the variable = $order_description
is only going to overwrite itself leaving only the last block of data displayed. How can i get it to display all in an email?
I can get that same script to work if i just echo them onto a webpage , but not with this because of the single variable used.
Any ideas?
Thank You!