Retrieving records from mysql [closed]
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
开发者_如何学编程 Improve this questionJust looking for better solution.I'm retrieving all the records from mysql. Then I will send this data by email. Its working fine. Is there any better solution? thanks
$query = "SELECT * FROM order_details WHERE order_id = '".$data['order_id']."'";
while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
$message_admin .= "<table style='text-align:center;' border='1' cellspacing='0' cellpadding='7'>
<tr>
<td>Source</td>
<td>".$data['source']."</td>
</tr>
<tr>
<td>Email</td>
<td>".$data['email']."</td>
</tr>
<tr>
<td>Message</td>
<td>".$data['message']."</td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</table>";
}
You would benefit from: http://us.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc
Instead of the complicated string manipulation you are doing now.
You are setting $row, but using $data?
I would take a look at the following to improve your code.
mysql-real-escape-string
SELECT * vs SELECT column
精彩评论