2016-06-28 48 views
-4

enter image description here天平沒有顯示

這裏是我的代碼:

<table width="50%" border="2" bordercolor="green"> 
    <tr> 
     <th>ItemName</th> 
     <th>Balance</th> 
    </tr> 
     <?php 
     if($qw="select DISTINCT(itemname) from details where DATE(date)<='$date' order by date desc"){ 
     $qq = mysqli_query($con,$qw); 
     while($r=mysqli_fetch_array($qq,MYSQLI_ASSOC)) 
     { 
     ?> 
     <tr> 
     <td><?php echo $r['itemname']; ?></td> 
     <td><?php echo $r['balance']; ?></td> 
     </tr> 
     <?php 
     } 
     } 
     ?> 
     </table> 

給定的代碼是獲取產品ITEMNAME但平衡不是從數據庫中獲取。

+2

因爲您不在SQL中選擇'balance'。 – Jeff

+2

'SELECT DISTINCT(itemname),balance ...' – Saty

+0

select DISTINCT(itemname),從DATE(date)<='$ date'按日期排序的詳細信息的餘額desc –

回答

0

您的查詢不包括'balance'字段。
更改您的查詢以包含它:

select DISTINCT itemname, balance from details where ... 
+0

查詢什麼即時消息是這樣if($ qw =「select DISTINCT(itemname),total from details where DATE(date)<='$ date'order by date desc」 ) – saurabh

+0

<表寬度= 「50%」 的邊界= 「2」 BORDERCOLOR = 「綠色」> \t \t \t ITEMNAME \t \t 餘額 \t \t <?PHP的 \t如果($ QW =「select DISTINCT(itemname),total fr om詳細信息DATE(日期)<='$ date'按日期排序desc「){ \t $ qq = mysqli_query($ con,$ qw); \t而($ R = mysqli_fetch_array($ QQ,MYSQLI_ASSOC)) \t { \t> \t \t \t \t​​ \t \t​​<?php echo $ r ['total']; ?> \t \t \t \t <?PHP \t} \t} \t?> \t – saurabh

+0

這也沒有工作 – saurabh