jaikob Posted December 13, 2008 Share Posted December 13, 2008 I am trying to create an invoice application that will send an invoice to a users email address. I am using the php mail function. I am successfully connected to mysql. What I want to do is repeat all rows returned, then store it in a string. I would send an email like this: <?php $to = $row_loggedin['email']; $subject = "Your Invoice For Order: ".$orderid; $body = "This is where all of the html junk goes"; $headers = "The headers"; mail($to, $subject, $body, $headers); ?> I have the $body set up with am html page with a table displaying the userrs quantity and product. Currently it will send the invoice with only one row. I need to repeat all rows, then capture it in a string so I can send it. I hope I made some sense. Link to comment https://forums.phpfreaks.com/topic/136843-solved-repeating-mysql-rows-and-storing-it-in-a-string/ Share on other sites More sharing options...
waynew Posted December 13, 2008 Share Posted December 13, 2008 Do you have a database table? If so, could you print it's structure here? Link to comment https://forums.phpfreaks.com/topic/136843-solved-repeating-mysql-rows-and-storing-it-in-a-string/#findComment-714700 Share on other sites More sharing options...
jaikob Posted December 13, 2008 Author Share Posted December 13, 2008 for example: id product_id temp_uuid user_id ordernum Is how my orders table is structured. I usually Join my products and orders table together. my SQL filters temp_uuid out, and returns those rows as the products ordered. I would format my string to be emailed like so: $body = "this is some html, then i place this in a table: ".row['product_id']."this is some more html"; My general problem is that it will only send one row. I cannot loop inside of a string. I do not know how to achieve what I want. I could loop the variable, but that would just send multiple emails. Link to comment https://forums.phpfreaks.com/topic/136843-solved-repeating-mysql-rows-and-storing-it-in-a-string/#findComment-714707 Share on other sites More sharing options...
jaikob Posted December 13, 2008 Author Share Posted December 13, 2008 Anyone? Link to comment https://forums.phpfreaks.com/topic/136843-solved-repeating-mysql-rows-and-storing-it-in-a-string/#findComment-714782 Share on other sites More sharing options...
DarkSuperHero Posted December 13, 2008 Share Posted December 13, 2008 im a bit confused as to what your trying to do....are you; a) trying to send out single e-mail to multiple clients with their unique individual invoices b) trying to build the html for the invoice then sending it to a single client, then (a). ? ///before this you connect and query the database for the certain user this might be put inside a loop $body = "<table>"; while ($row = mysql_fetch_row($result)) { $body .= "<tr>"; $body .= "<td>"; $body .= $row[1]; $body .= "</td>"; $body .= "</tr>"; }; $body .="</table>"; $to = $some_one; $subject = "Your Invoice For Order: ".$orderid; $headers = "The headers"; mail($to, $subject, $body, $headers); //close possible outer loop....and continue to next client.... hope that kinda makes some sence.... Link to comment https://forums.phpfreaks.com/topic/136843-solved-repeating-mysql-rows-and-storing-it-in-a-string/#findComment-714801 Share on other sites More sharing options...
jaikob Posted December 13, 2008 Author Share Posted December 13, 2008 im a bit confused as to what your trying to do....are you; a) trying to send out single e-mail to multiple clients with their unique individual invoices b) trying to build the html for the invoice then sending it to a single client, then (a). ? ///before this you connect and query the database for the certain user this might be put inside a loop $body = "<table>"; while ($row = mysql_fetch_row($result)) { $body .= "<tr>"; $body .= "<td>"; $body .= $row[1]; $body .= "</td>"; $body .= "</tr>"; }; $body .="</table>"; $to = $some_one; $subject = "Your Invoice For Order: ".$orderid; $headers = "The headers"; mail($to, $subject, $body, $headers); //close possible outer loop....and continue to next client.... hope that kinda makes some sence.... Thanks!! I got it. Link to comment https://forums.phpfreaks.com/topic/136843-solved-repeating-mysql-rows-and-storing-it-in-a-string/#findComment-714809 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.