我已经搜索了正确的答案,但没有一个帮助我解决这个错误。我有一个名为profile.php
的页面,其中有3个不同的选项卡,其中包含从mysqli数据库生成的一些信息。问题是我必须在第三个标签中显示我已编写一些代码的订单。如果没有订单,则应输出“到目前为止没有订单!!”。它显示消息但它也显示警告。
警告:mysqli_num_rows()要求参数1为mysqli_result,在第211行的D:\ XAMPP \ htdocs \ WebProject \ profile.php中给出布尔值
以下是第三个标签的代码。
代码
<div id="menu3" class="tab-pane fade">
<h3>My Orders</h3>
<?php
$q="select customers.*, orders.date,orders.status from orders inner join customers on orders.customerid=customers.serial_cust where customers.email='$email'" ;
$result=mysqli_query($con,$q);
if(mysqli_num_rows($result)>0){
while($row=mysqli_fetch_array($result))
{
$custid=$row['serial_cust'];
$ordersdate=$row['date'];
echo "<tr>";
echo "<h3>".$row['date']."</h3>";
echo "<h3> Status: Dispatched -> </h3> <p>".$row['status']."</p>";
echo"<table border='1'>";
$query="select customers.*, order_detail.*,orders.date,orders.customerid,products.* from order_detail inner join orders on orders.serial=order_detail.orderid inner join products on products.productid=order_detail.productid inner join customers on orders.customerid=customers.serial_cust where customers.serial_cust='$custid' and orders.date='$ordersdate' ";
$sql=mysqli_query($con,$query);
while($row=mysqli_fetch_array($sql))
{
?>
<tr>
<td><image width="80px" height="90px" src="assets/<?php echo $row['product_image'] ?>"/></td>
<td><?php echo $row['product_name']. " * ". $row['quantity']?></td>
<td><?php echo $row['color'] ?></td>
<td><?php echo $row['price'] ?></td>
<td><?php echo $row['size'] ?></td>
</tr>
<?php
}
echo "</table>";
}
}
else{
echo "You have not place any orders yet!";
}
?>
</div>
答案 0 :(得分:0)
您的请求中可能存在错误。使用此代码进行调试:
$q="select customers.*, orders.date,orders.status from orders inner join customers on orders.customerid=customers.serial_cust where customers.email='$email'" ;
$result=mysqli_query($con,$q);
if (!$result)
echo(mysqli_error($con));
if(mysqli_num_rows($result)>0){
...
}