dsnyder Posted June 18, 2010 Share Posted June 18, 2010 I am trying to send the reults of a mysql query as a list in an email. If I use the same code to print the reults using echo it works fine, but I cant Figure out how to send them in an email listing them the same as it does when using echo (showing results not emailing). Any Help would greatly be appreciated I am pulling my hair out. The Problem is that $services are not listed in the email. It shows one row of results only. NOTE: $services are in the middle of the message. Here is the code I have . <?php require('../includes/invconfig.php'); $query = "SELECT * FROM inv_services WHERE invid = '$invid'"; $result = mysql_query($query); while ($row = mysql_fetch_array($result)) { $invtype = $row[invtype]; $invdesc = $row[invdesc]; $invdomain = $row[invdomain]; $invcost = $row[invcost]; $i++; $services = "$invservtype $invserv_desc $invserv_domain $invserv_cost"; } $sendemail = "$_POST[emailaddress]"; $subject = "Invoice Number: $invnumb"; $fromName = "$sysemailfrom"; $fromAddress = "$sysemail"; $message = "Dear $bill_name,\n\nBelow Please Find Your Invoice # $invnumb That You Requested be Sent to this email address.\n =======================================================================\n INVOICE NUMBER: $invnumb\n\n$line1\n$line2\n$line3\n$line4\n$line5\n$line6\n =======================================================================\n INVOICE DATE:$invdate\nSERVICE DATES: $invstart Thru $invend\n\nINVOICE STATUS: $invstatus\nDATE PAID: $paiddate\n =======================================================================\n ACCOUNT ID: $acctid\n\n$bill_company\n$bill_name\n$bill_address\n$bill_city, $bill_state, $bill_zip. $bill_country\n =======================================================================\n $services\n\nINVOICE TOTAL: $invtotal\n =======================================================================\n\n If You Have any Questions Regarding This Invoice Please Contact Our Billing Department at: $sysbillemail\n\nThank You\n\n"; mail($sendemail, $subject, $message, "From: ".$fromName." <".$fromAddress.">"); header("Location: invoice_sent.php"); ?> Link to comment https://forums.phpfreaks.com/topic/205130-send-query-results-as-a-list-in-email/ Share on other sites More sharing options...
Pikachu2000 Posted June 18, 2010 Share Posted June 18, 2010 Where are $inveservtype, $invserv_desc, $invserv_domain, and $invserv_cost assigned values? Since none of those appear to have values, I can only imagine that $services would not have a value either. $services = "$invservtype $invserv_desc $invserv_domain $invserv_cost"; Link to comment https://forums.phpfreaks.com/topic/205130-send-query-results-as-a-list-in-email/#findComment-1073731 Share on other sites More sharing options...
dsnyder Posted June 18, 2010 Author Share Posted June 18, 2010 Hi.. Thanks for the Reply... The total code is Very Long and I just provided the portion pertinent to my question and made some changes to simplify and made a couple errors in my efforts to simplify. Sorry about that! Here is the code again.. <?php require('../includes/invconfig.php'); $query = "SELECT * FROM inv_services WHERE invid = '$invid'"; $result = mysql_query($query); while ($row = mysql_fetch_array($result)) { $invtype = $row[invtype]; $invdesc = $row[invdesc]; $invdomain = $row[invdomain]; $invcost = $row[invcost]; $i++; $services = "$invtype $invdesc $invdomain $invcost"; } $sendemail = "$_POST[emailaddress]"; $subject = "Invoice Number: $invnumb"; $fromName = "$sysemailfrom"; $fromAddress = "$sysemail"; $message = "Dear $bill_name,\n\nBelow Please Find Your Invoice # $invnumb That You Requested be Sent to this email address.\n =======================================================================\n INVOICE NUMBER: $invnumb\n\n$line1\n$line2\n$line3\n$line4\n$line5\n$line6\n =======================================================================\n INVOICE DATE:$invdate\nSERVICE DATES: $invstart Thru $invend\n\nINVOICE STATUS: $invstatus\nDATE PAID: $paiddate\n =======================================================================\n ACCOUNT ID: $acctid\n\n$bill_company\n$bill_name\n$bill_address\n$bill_city, $bill_state, $bill_zip. $bill_country\n =======================================================================\n $services\n\nINVOICE TOTAL: $invtotal\n =======================================================================\n\n If You Have any Questions Regarding This Invoice Please Contact Our Billing Department at: $sysbillemail\n\nThank You\n\n"; mail($sendemail, $subject, $message, "From: ".$fromName." <".$fromAddress.">"); header("Location: invoice_sent.php"); ?> As I originally Mentioned if I use echo with this same code it works. So this works.. <?php $query = "SELECT * FROM inv_services WHERE invid = '$invid'"; $result = mysql_query($query); while ($row = mysql_fetch_array($result)) { $invtype = $row[invtype]; $invdesc = $row[invdesc]; $invdomain = $row[invdomain]; $invcost = $row[invcost]; $i++; echo "$invtype $invdesc $invdomain $invcost<br>"; } ?> What I need is for the same output as the above code produces to be in the email in the place I have $services (in the $message = "" I really appreciate any help or suggestions. Link to comment https://forums.phpfreaks.com/topic/205130-send-query-results-as-a-list-in-email/#findComment-1073853 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.