rbueno Posted September 3, 2009 Share Posted September 3, 2009 Hello there! My problem is, I have data from my database, i want to fetch it(successful) and email the content in table:'(.. switch ($_GET['action']) { case 'sendmultiple'; //fecth data from database $id = $_GET['id']; $email = $_POST['emails']; $name = $_POST['name']; if($_POST['email'] ==''){ $info = "Please enter your customer's email!"; } elseif(!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)){ $info = "Please enter valid email address! ex. [email protected]"; } elseif($_POST['name']==''){ $info = "Please enter your customer's name!"; }else{ $sql = mysql_query("select * from temp where users_id = '" . $_SESSION['valid_user'] . "'") or die(mysql_error()); if (mysql_num_rows($sql) > 0) { $i = 0; while ($result = mysql_fetch_assoc($sql)) { $class = $i % 2 == 0 ? 'light' : 'dark'; $model_id = $result['model_id']; $sql_data = mysql_query("select * from model where id = '$model_id'") or die(mysql_error()); while($result_model = mysql_fetch_array($sql_data)){ //$result_model = mysql_fetch_array($sql_data); $image = $result_model['id']; $headers= 'MIME-Version: 1.0' . "\r\n"; $headers.= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers.= 'To: ' . $name . '<' . $email . '>' . "\r\n"; $headers.= 'From: [email protected]' . "\r\n"; //message $mail_content= "Hi $name,<br/><br/>"; $mail_content.= "Below is the model you have requested!<br/><br/>"; $mail_content.= "<table BORDER = \"1\"> <tr> <th>Model Thumbnail</th><th>Model Name</th><th>Date Unavailability</th><th>Links</th> </tr> <tr> <td><img src = \"*****/images/model/{$result_model['model_image']}\" alt = \"{$result_model['model_name']}\" width = \"150px\" align = \"center\"></td><td>{$result_model['model_name']}</td><td>{$result_model['model_unavailability']}</td><td><a href = \"******/view_model.php?id={$result_model['id']}\">Click here for more info..</a></td> </tr> </table>"; } mail($_POST['email'], 'Model Requested', $mail_content, $headers); header('Location: send.php?action=emailsuccess'); } } } break; } don't mind about the session =0 Link to comment https://forums.phpfreaks.com/topic/172935-how-to-email-database-content-in-and-display-in-table/ Share on other sites More sharing options...
trq Posted September 3, 2009 Share Posted September 3, 2009 My problem is, I have data from my database, i want to fetch it(successful) and email the content in table:'(. That isn't a problem, just a description of what you want to do. Mind telling us which part of that process isn't working? Link to comment https://forums.phpfreaks.com/topic/172935-how-to-email-database-content-in-and-display-in-table/#findComment-911443 Share on other sites More sharing options...
rbueno Posted September 3, 2009 Author Share Posted September 3, 2009 Thanks for your reply!. Actually, the problem is that the data sent is one by one. for example: i have 2 records and i email that data.. i want that 2 records will send as one email and in a table format BUT, i have received two emails that contain one by one record.. i don't have any error message but i think the process that is not working properly is this one: $sql_data = mysql_query("select * from model where id = '$model_id'") or die(mysql_error()); while($result_model = mysql_fetch_array($sql_data)){ //$result_model = mysql_fetch_array($sql_data); $image = $result_model['id']; $headers= 'MIME-Version: 1.0' . "\r\n"; $headers.= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers.= 'To: ' . $name . '<' . $email . '>' . "\r\n"; $headers.= 'From: [email protected]' . "\r\n"; //message $mail_content= "Hi $name,<br/><br/>"; $mail_content.= "Below is the model you have requested!<br/><br/>"; $mail_content.= "<table BORDER = \"1\"> <tr> <th>Model Thumbnail</th><th>Model Name</th><th>Date Unavailability</th><th>Links</th> </tr> <tr> <td><img src = \"*****/images/model/{$result_model['model_image']}\" alt = \"{$result_model['model_name']}\" width = \"150px\" align = \"center\"></td><td>{$result_model['model_name']}</td><td>{$result_model['model_unavailability']}</td><td><a href = \"******/view_model.php?id={$result_model['id']}\">Click here for more info..</a></td> </tr> </table>"; } mail($_POST['email'], 'Model Requested', $mail_content, $headers); header('Location: send.php?action=emailsuccess'); As it send one data per email.. Link to comment https://forums.phpfreaks.com/topic/172935-how-to-email-database-content-in-and-display-in-table/#findComment-911457 Share on other sites More sharing options...
trq Posted September 3, 2009 Share Posted September 3, 2009 Move this.... mail($_POST['email'], 'Model Requested', $mail_content, $headers); header('Location: send.php?action=emailsuccess'); outside of your while loop. Link to comment https://forums.phpfreaks.com/topic/172935-how-to-email-database-content-in-and-display-in-table/#findComment-911458 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.