2013-07-07 40 views
-1

我創建了一個名爲prod_det.php的頁面。該頁面顯示產品的詳細信息。下面是代碼。但它不起作用。當我點擊詳細信息按鈕警告接收錯誤消息:mysql_fetch_array()預計參數1是資源,布爾僅在關閉按鈕的彈出窗口中顯示產品詳細信息

<?php 
session_start(); 
?> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Product</title> 
<link href="CSS/product.css" rel="stylesheet" type="text/css" /> 
</head> 

<body> 

<?php 

//Create the connection and select the DB 
include('db_connect.php'); 

// Select records from the DB 

$query = "SELECT p.prod_name, p.prod_photo, pr.prod_price, pr.prod_desc, pr.prod_brand, pr.prod_w_c 
      FROM tblproduct p 
      INNER JOIN tblretprod pr ON p.prod_id = pr.prod_id"; 
$result = mysql_query($query); 

// Display records from the table ?> 

<?php while ($row = mysql_fetch_array($result)): ?> 

<div class="prod_box_big"> 
    <div class="top_prod_box_big"></div> 
     <div class="center_prod_box_big">    

      <div class="product_img_big"><?= '<img height="100" width="100" src="Images/Products/'.$row['prod_photo'].'"/>'; ?> 
       <div class="thumbs"><?= $row['prod_desc']; ?></div> 
      </div> 
       <div class="details_big_box"> 
        <div class="product_title_big"><?= $row['prod_name']; ?></div> 
        <div class="specifications"> 
         Brand: <span class="blue"><?= $row['prod_brand']; ?></span><br /> 

         Quantity: <span class="blue"><?= $row['prod_w_c']; ?></span><br /> 

         Price include <span class="blue">TVA</span><br /> 
        </div> 
        <div class="prod_price_big"><span class="reduce"><?= $row['prod_price']; ?> </span> <span class="price">%promo%</span></div> 

        <a href="#" class="addtocart">add to fav</a> 
        <a href="#" class="compare">compare</a> 
       </div>       
     </div> 
     <div class="bottom_prod_box_big"></div>         
</div> 
<?php endwhile; ?> 

</body> 
</html> 
+0

可能重複[Warning:mysql \ _fetch \ _array()期望參數1爲資源\ [... \]](http://stackoverflow.com/questions/5470533/warning-mysql-fetch-array -expect-parameter-1-to-resource) – mario

+0

[mysql \ _fetch \ _array()的可能的重複需要參數1爲資源,布爾在select中選擇](http://stackoverflow.com/questions/2973202/ mysql-fetch-array-expects-parameter-1-to-resource-boolean-given-in-select) –

+0

請參閱[本答案](http://stackoverflow.com/a/11674313/250259)瞭解如何解決這個問題。 –

回答

0

這意味着您的查詢失敗,所以$結果將被設置爲FALSE。

您可以通過調用mysql_error function來查看錯誤消息。

+0

現在的問題是每個產品顯示都有一個產品詳細信息按鈕。當我點擊我的產品詳細信息按鈕時,顯示所有產品的詳細信息,而不是我點擊的產品的詳細信息。請解決這個問題的任何幫助? – user2534128

+0

我認爲這是用一些JavaScript應該顯示適當的「details_big_box」div?如果是這樣,我建議你關閉這個問題並提交一個包含你正在使用的JavaScript的新問題。 –

相關問題