【发布时间】:2011-11-22 23:18:15
【问题描述】:
我在电子商务网站中有一个管理区域,管理员可以在此查看 allusers.php 页面上的所有用户。用户在表格中列出了他们的个人信息,但是我在每个用户附近都有一个“查看个人资料”按钮,如果您单击它,它将带您到另一个页面,您可以在其中查看特定用户过去的订单。
以下是我为 allusers.php 编写的代码:
<?php
$result = mysql_query("SELECT * FROM customers ")
or die(mysql_error()); ;
if (mysql_num_rows($result) == 0) {
echo 'There Arent Any Orders Yet';
} else {
echo "<table border='0'><table border width=100%><tr><th>First Name</th><th>Surname</th><th>Address</th><th>E-Mail</th><th>Username</th><th>View Profile</th>";
while($info = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $info['name']. "</td>";
echo "<td>" . $info['surname']. "</td>";
echo "<td>" . $info['address1']. $info['address2']. $info['city']. $info['postcode']." </td>";
echo "<td>" . $info['email']. "</td>";
echo "<td>" . $info['username']. "</td>";
echo "<td>" . " <a href='view.php'>View</a> </td>";
}
}
echo "</tr>";
echo "</table>";
?>
view.php页面如下:
<?php
$result = mysql_query("SELECT * FROM order WHERE ......dont know what to enter here")
or die(mysql_error()); ;
if (mysql_num_rows($result) == 0) {
echo 'There Arent Any Orders For This Customer Yet';
} else {
echo "<table border='0'><table border width=100%><tr><th>Product</th><th>Quantities</th><th>Date</th>";
while($info = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $info['name']. "</td>";
echo "<td>" . $info['quantity']. "</td>";
echo "<td>" . $info['date']. " </td>";
}
}
echo "</tr>";
echo "</table>";
?>
我有一个包含以下字段和表的 mysql 数据库:
客户 - id、姓名、姓氏、地址 1、地址 2、城市、邮政编码、电子邮件、用户名、密码
产品 - 序列号、名称、描述、价格、图片
订单 - id、名称、数量、价格、日期、用户名
感谢您提供的任何帮助
【问题讨论】:
标签: php mysql error-handling datatable