php - dynamic table in email -


i have been trying last few hours create dynamic table within email.. , have been unsuccuessful have tried create tables in , out of body varible , echo within have had no success have placed code bellow.. anyhelp great thanks.. im trying create table mysql data within , send clients.. thats run down of have been attemoting complete

$link = mysql_connect('localhost', 'root', '');     mysql_select_db('netbookdb');     $sql="select * rep_log s_date = '2012-05-31'";     $result=mysql_query($sql, $link);   $date=date('dmy'); require("../phpmailer/class.phpmailer.php"); $mail = new phpmailer();$mail = new phpmailer(); $mail->issmtp();    // set mailer use smtp $mail->host = "smtp";    // specify main , backup server  $mail->from = "support@.vic.edu.au";     $mail->fromname = "ict devices";    $mail->addaddress("email@h.vic.edu.au", "matthew");   $mail->subject = "damage log report";  $mail->ishtml(true); $var='xlsx'; $date=date('dmy.');  $mail->body = " while($rows=mysql_fetch_array($result)){         $cases=$rows['cases'];         $hg=$rows['hg'];         $surname=$rows['surname'];         $firstname=$rows['firstname'];         $claim=$rows['claim'];         $damage=$rows['damage'];         $cost=$rows['cost'];      }"; $mail->altbody="please use html compaible email veiwer";    if(!$mail->send()) {    echo "error sending: " . $mail->errorinfo;; } else {    echo "letter sent"; } 

i used peace of code created script create dynamic table , echo out body of email basic table improvements can made

$link = mysql_connect('localhost', 'root', '');     mysql_select_db('your dataabse name');     $sql="select * rep_log claim='insurance' , s_date = '2012-05-31'";     $result=mysql_query($sql, $link);  $table= "<table width='100%' border='3' cellspacing='0' cellpadding='0'>"; $table .="<th>cases</th>"; $table .="<th>hg</th>"; $table .="<th>surname</th>"; $table .="<th>fristname</th>"; $table .="<th>claim</th>"; $table .="<th>damage</th>"; $table .="<th>cost</th>";      while($rows=mysql_fetch_array($result)){         $cases=$rows['cases'];         $hg=$rows['hg'];         $surname=$rows['surname'];         $firstname=$rows['firstname'];         $claim=$rows['claim'];         $damage=$rows['damage'];         $cost=$rows['cost'];     $table .="<tr>";     $table .="<td>$cases</td>";     $table .="<td>$hg</td>";     $table .="<td>$surname</td>";     $table .="<td>$firstname</td>";     $table .="<td>$claim</td>";     $table .="<td>$damage</td>";     $table .="<td>$cost</td>";     $table .="</tr>";       } $table .="</table>";  $date=date('dmy'); require("../phpmailer/class.phpmailer.php"); $mail = new phpmailer();$mail = new phpmailer(); $mail->issmtp();    // set mailer use smtp $mail->host = "smtp";    // specify main , backup server  $mail->from = "support@ac.vic.edu.au";     $mail->fromname = "ict devices";    $mail->addaddress("gs@hum.vic.edu.au", "matthew");   $mail->subject = "damage log report";  $mail->ishtml(true); $var='xlsx'; $date=date('dmy.');  $mail->body = "$table;"; $mail->altbody="please use html compaible email veiwer";    if(!$mail->send()) {    echo "error sending: " . $mail->errorinfo;; } else {    echo "letter sent"; } 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -