php - sending email with all products from cart -
first of im noob when comes coding il try explain im trying send email products cart table customer, can send last row of cart table, when im echoing var's prints me products need.
$message =""; $message2 =""; $trxformail = "select * orders trx_id = '$trx_id'"; $run_trx = mysqli_query($con, $trxformail); while($post_trx = mysqli_fetch_array($run_trx)){ $pro_id = $post_trx['p_id']; $pro_price = "select * products product_id='$pro_id'"; $run_pro_price = mysqli_query($con,$pro_price); while($pp_price = mysqli_fetch_array($run_pro_price)){ $product_price = array($pp_price['product_price']); $product_id = $pp_price['product_id']; $qty = $pp_price['product_qty']; $pro_name = $pp_price['product_title']; $pro_makat = $pp_price['product_makat']; $values = array_sum($product_price); $total +=$values*$p_price['qty']; $headers = "mime-version: 1.0" . "\r\n"; $headers .= "content-type:text/html;charset=utf-8" . "\r\n"; $headers .= 'from: <blah@blah.com>' . "\r\n"; $subject = "פרטי ההזמנה שלכם באתר 'סלינה'"; echo $pro_name; echo $qty; $message .= "<html> <p dir='rtl'> שלום רב, <b style='color:#cc00cc;'>$c_name</b>, אנו מודים לכם על שקניתם אצלינו, ההזמנה שלכם תטופל בהקדם האפשרי. </p> <table width='600' align='center' bgcolor='white' border='1' dir='rtl'> <tr align='center'><td colspan='6'><h2>פרטי ההזמנה שלכם</h2></td></tr> <tr align='center'> <th><b>מ.מ</b></th> <th><b>שם המוצר</b></th> <th><b>כמות</b></th> <th><b>שולם</th></th> <th>מספר ההזמנה</th> </tr> <tr align='center'> <td>1</td> <td>" . $pro_name . "</td> <td>" . $qty . "</td> <td>$total</td> <td>$invoice</td> </tr> </table> </html>"; }
i changed code around little bit, see here
<?php $message =""; $message2 =""; $trxformail = "select * orders trx_id = '$trx_id'"; $run_trx = mysqli_query($con, $trxformail); while($post_trx = mysqli_fetch_array($run_trx)){ $pro_id = $post_trx['p_id']; $pro_price = "select * products product_id='$pro_id'"; $run_pro_price = mysqli_query($con,$pro_price); while($pp_price = mysqli_fetch_array($run_pro_price)){ $product_price = array($pp_price['product_price']); $product_id = $pp_price['product_id']; $messagerows['qty'] = $pp_price['product_qty']; $messagerow['pro_name'] = $pp_price['product_title']; $messagerows['pro_makat'] = $pp_price['product_makat']; $values = array_sum($product_price); $messagerows['total'] = $values*$p_price['qty']; $msg[]=$messagerows; } $headers = "mime-version: 1.0" . "\r\n"; $headers .= "content-type:text/html;charset=utf-8" . "\r\n"; $headers .= 'from: <blah@blah.com>' . "\r\n"; $subject = "פרטי ההזמנה שלכם באתר 'סלינה'"; $message = "<html> <p dir='rtl'> שלום רב, <b style='color:#cc00cc;'>$c_name</b>, אנו מודים לכם על שקניתם אצלינו, ההזמנה שלכם תטופל בהקדם האפשרי. </p> <table width='600' align='center' bgcolor='white' border='1' dir='rtl'> <tr align='center'><td colspan='6'><h2>פרטי ההזמנה שלכם</h2></td></tr> <tr align='center'> <th><b>מ.מ</b></th> <th><b>שם המוצר</b></th> <th><b>כמות</b></th> <th><b>שולם</th></th> <th>מספר ההזמנה</th> </tr>"; $i = 1; foreach($msg $row){ $message .= "<tr align='center'> <td>" . $i . "</td> <td>" . $row['pro_name'] . "</td> <td>" . $row['qty'] . "</td> <td>" . $row['total'] . "</td> <td>" . $invoice . "</td> </tr>"; $i++; } $message .= "</table></html>"; mail($to,$subject,$message,$headers);
Comments
Post a Comment