2016-01-30 37 views
1

我已經搜索了正確的答案,但沒有一個幫助我解決了這個錯誤。我有一個名爲profile.php的頁面,其中有3個不同的選項卡,其中有一些來自mysqli數據庫的信息。問題是我必須在第三個標籤中顯示我已經寫了一些代碼的訂單。如果沒有下訂單,它應該輸出「沒有訂單直到現在!!」。它顯示消息,但它也顯示警告。mysqli_num_rows()期望參數1爲mysqli_result,

警告:mysqli_num_rows()預計參數1被mysqli_result,布爾在d給出:\ XAMPP \ htdocs中\ WebProject \ profile.php上線211

這裏是我的第三個選項卡的代碼。

代碼

<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

檢查您的查詢。 –

+2

在您的查詢中使用die,以便您可以獲取mysql錯誤。 'mysql_query($ con,$ q)或死(mysql_error());' –

+1

將你的查詢複製並粘貼到phpmyadmin(查詢標籤)中,然後告訴你看到了什麼。 –

回答

0

Propably你有你的請求錯誤。使用此代碼進行調試:

$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){ 
... 
} 
+0

這解決了這個問題! :) – tabia

相關問題