<?php
include_once 'db.php';
$email = $_GET['email'];
$order_id = $_GET['order_id'];
$res=mysql_query("SELECT * FROM clients_buy WHERE email='$email'");
$row=mysql_fetch_array($res);
echo "<table border='1'>
<tr>
<th><center>order_id</center></th>
<th><center>item1</th>
<th><center>item2</th>
<th><center>item3</th>
<th><center>item4</th>
<th><center>item5</th>
</tr>";
while($row = mysql_fetch_assoc($res))
$row[] = $row;
echo "<tr>";
echo "<td><center>" . $row['user_id'] . "</center></td>";
echo "<td><center>" . $row['item1'] . "</center></td>";
echo "<td><center>" . $row['item2'] . "</center></td>";
echo "<td><center>" . $row['item3'] . "</center></td>";
echo "<td><center>" . $row['item4'] . "</center></td>";
echo "<td><center>" . $row['item5'] . "</center></td>";
echo '</tr>';
echo '</table>';
?>
我想在php页面中显示从一个用户发出的所有订单。
答案 0 :(得分:0)
正如Sand评论的那样,请使用mysqli或PDO。为什么你在while循环中没有花括号?虽然没有测试过您的代码,但这似乎是一个错误的过程。 我会把它写成
while($row = mysql_fetch_assoc($res)){
echo "<tr>";
echo "<td><center>" . $row['user_id'] . "</center></td>";
echo "<td><center>" . $row['item1'] . "</center></td>";
echo "<td><center>" . $row['item2'] . "</center></td>";
echo "<td><center>" . $row['item3'] . "</center></td>";
echo "<td><center>" . $row['item4'] . "</center></td>";
echo "<td><center>" . $row['item5'] . "</center></td>";
echo '</tr>';
}
echo '</table>';