2014-08-29 79 views
-2

我有問題。我想從表STAF顯示NAMA有相同身份證身份證從表tempahan。我試着做下面代碼一樣,但我只是唯一的錯誤加入與特定行的多個表

警告:mysqli_fetch_array()預計參數1被mysqli_result,在C定的boolean:\ XAMPP \ htdocs中\新建文件夾\ permohonan_stk.php 120線上

有人可以幫我嗎?

<?php 
     include 'include\opendb.php'; 
     $i = "SELECT tempahan.tarikh_mohon, tempahan.tarikh, tempahan.masa_dari, tempahan.masa_hingga, tempahan.dari_daerah, tempahan.hingga_daerah, tempahan.tujuan, tempahan.status, staf.nama, staf.nric 
     from tempahan, staf 
     WHERE staf.nric = tempah.nric"; 
     $h = mysqli_query($mysqli, $i);   
     $row=mysqli_fetch_array($h); 



     while($row1){ 

    ?> 

    <tr> 

     <td><center><?php echo $row['tarikh_mohon']; ?></center></td> 
     <td><center><?php echo $row['nama']; ?></center></td> 
     <td><center><?php echo $row['tarikh']; ?></center></td> 
     <td><center><?php echo $row['masa_dari']; ?></center></td> 
     <td><center><?php echo $row['masa_hingga']; ?></center></td> 
     <td><center><?php echo $row['dari_daerah']; ?></center></td> 
     <td><center><?php echo $row['dari_daerah']; ?></center></td> 
     <td><center><?php echo $row['tujuan']; ?></center></td> 
     <td><center><?php echo $row['status']; ?></center></td> 
    </tr> 
    <?php 
     } 

    ?> 
+0

[**看到這個太**](http://stackoverflow.com/questions/16756596/警告 - mysqli-num-rows-expect-parameter-1-to-mysqli-result-boolean-give):) – NoobEditor 2014-08-29 05:52:47

+0

終於我得到了答案。我需要檢查查詢,因爲查詢失敗。 – 2014-08-29 08:42:45

+0

tq @NoobEditor幫助 – 2014-08-29 08:43:00

回答

0

請看到這一點:

$con=mysqli_connect("localhost","user","password","my_db"); 
// Check connection 
if (mysqli_connect_errno()) 
    { 
    echo "Failed to connect to MySQL: " . mysqli_connect_error(); 
    } 

$sql="SELECT tempahan.tarikh_mohon, tempahan.tarikh, tempahan.masa_dari, 
tempahan.masa_hingga, tempahan.dari_daerah, tempahan.hingga_daerah, tempahan.tujuan, tempahan.status, staf.nama, staf.nric 
from tempahan, staf WHERE staf.nric = tempah.nric"; 

$result=mysqli_query($con,$sql) 

// Numeric array 
$row=mysqli_fetch_array($result,MYSQLI_NUM); 

while($row1){ 

    ?> 
..................... 
............... 

更多refernce到mysql_fetch_array:http://php.net/manual/en/function.mysql-fetch-array.php

+0

我已經找到答案了。我只需要先查詢查詢。 tq fo help me – 2014-08-29 08:44:47