'."\n".mysql_error()); } $fields = mysql_num_fields ( $s ); // echo($sql); //Send Mail //add From: header $headers = "From: panya.p@jasmine.com\r\n"; //specify MIME version 1.0 $headers .= "MIME-Version: 1.0\r\n"; //unique boundary $boundary = uniqid("HTMLMAIL"); //tell e-mail client this e-mail contains//alternate versions $headers .= "Content-Type: multipart/mixed; boundary = $boundary\r\n\r\n"; //plain text version of message //$body = "--$boundary\r\n" . // "Content-Type: text/plain; charset=windows-874\r\n" . // "Content-Transfer-Encoding: base64\r\n\r\n"; //$body .= chunk_split(base64_encode("This is the plain text version! ทดสอบครับ")); //HTML version of message $body .= "--$boundary\r\n" . "Content-Type: text/html; charset=windows-874\r\n" . "Content-Transfer-Encoding: base64\r\n\r\n"; $body_msg = ' Sabaydee Plus Location tracking report for PhoneID '.$phone_id.'
Sabaydee Plus Location tracking report

PhoneID:
'; for($i=1;$i<$fields;$i++){ $body_msg .=''; } $sum_column = array(); $sum_column[] = 0; $irow = 0; while ($row = mysql_fetch_assoc($s)) { $body_msg .=''; $irow++; $ireset = 0; foreach( $row as $value ) { if(($ireset >2)){ $nvalue = number_format($value,2); }else{ $nvalue = $value; } if(($irow%2)==0 ){ $body_msg .=''; }else{ $body_msg .=''; } $sum_column[$ireset] += $value; $ireset++; } // $ireset=0; } //while $body_msg .= ""; // mysql_close($link); // Sum value /*for($i=0;$i<$fields;$i++){ if(($i ==2) || ($i ==3)||($i>=6)){ $body_msg .=''; }else{ $body_msg .=''; } } */ $body_msg .=''; $body_msg .=' '; for($i=1;$i<$fields;$i++){ $body_msg .=''; }; $body_msg .='
'.mysql_field_name($s, 0).''.mysql_field_name($s, $i).'
'.$nvalue.''.$nvalue.'
'.number_format($sum_column[$i],2).' 
'.mysql_field_name($s, 0).''.mysql_field_name($s, $i).'
'; $body_msg .='
'; $body .= chunk_split(base64_encode($body_msg)); mysql_close($link); //send message //mail($to_email, "Top 50 destination & custgroup for cybervoice of ".$report_data_date, $body, $headers); //mail($to_email1, "Top 50 destination & custgroup for cybervoice of ".$report_data_date, $body, $headers); //mail($to_email2, "Top 50 destination & custgroup for cybervoice of ".$report_data_date, $body, $headers); //mail($to_email3, "Top 50 destination & custgroup for cybervoice of ".$report_data_date, $body, $headers); //echo "Report Send.
"; echo $body_msg; ?>