IrOnMaSk Posted June 28, 2011 Share Posted June 28, 2011 Hi, guys not sure if this is the right place for php-mysql help. So, I've been search for 2 weeks now how to send a query result in an email. I know how to do a simple putting the query into a html table and send it using $message .= blablabla. but what i'm looking for is little bit complicated. Any of you looking for a challenge, I promise this will be a challenge (I hope!!!). So I have a table function and call it every time I need to use it rather than create table and <tr><td> and put it into the message body. I don't know how to put the table function into the message body and send through email. here's the code: <?php function viewtable($result) { include 'opendb.php'; if ($conn) { echo "<table border=\"0\" border-width=\"thin\" valign=\"top\" cellspacing=\"3\" cellpadding=\"3\" width=\"100%\"><tr>"; //print field name $colName = odbc_num_fields($result); for ($j=1; $j<= $colName; $j++) { if (odbc_field_name($result,$j) != "App_ID") { echo "<th align=\"left\">"; echo odbc_field_name ($result, $j ); echo "</th>"; } } //fetch the data from the database while(odbc_fetch_row($result)) { echo "<tr align=\"left\">"; for($i=1;$i<=odbc_num_fields($result);$i++) { if (odbc_field_name($result,$i) == "App_ID") { $app = odbc_result($result,$i); } else { echo "<td align=\"left\">"; if (odbc_field_name($result,$i) == "Amount Due" || odbc_field_name($result,$i) == "Net Due") {echo "$";} echo odbc_result($result,$i); echo "</td>"; } } echo "<TD><br><form method = \"post\" action = \"app.php\">"; echo "<input type = \"hidden\" name = \"app\" value = $app>"; echo "<input type = \"submit\" value = \"View Application\"></form></TD>"; echo "</TR>"; } echo "</td> </tr>"; echo "</table >"; } else echo "odbc not connected"; } function useful_odbc_num_rows($result){ $num_rows=0; while($temp = odbc_fetch_into($result, $counter)) { $num_rows++; } @odbc_fetch_row($result, 0); // reset cursor return $num_rows; } ?> The rest is in the attachment... Challenging you, helping me I'm in the wrong place, have some grace and direct to the right one.... thanks in advance MOD EDIT: code tags added. [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/240571-send-query-through-email/ Share on other sites More sharing options...
Pikachu2000 Posted June 28, 2011 Share Posted June 28, 2011 When posting code, enclose it within the forum's . . . BBCode tags. Quote Link to comment https://forums.phpfreaks.com/topic/240571-send-query-through-email/#findComment-1235747 Share on other sites More sharing options...
IrOnMaSk Posted July 8, 2011 Author Share Posted July 8, 2011 Never Mind, I solved the problem. If anyone looking for similar solution let me know <?php echo "I\'m Neo"; Echo "Or The ONE"; ?> </php] Quote Link to comment https://forums.phpfreaks.com/topic/240571-send-query-through-email/#findComment-1240224 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.