-2

i have a question. i want to display nama from table staf that have same nric with nric from table tempahan. i try to do like code below but i just only error

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\New folder\permohonan_stk.php on line 120

can anybody help me?

    <?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
        }

    ?>
NoobEditor
  • 14,879
  • 17
  • 75
  • 106

1 Answers1

0

Please see this:

$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 ){

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

For more refernce to mysql_fetch_array : http://php.net/manual/en/function.mysql-fetch-array.php

Naincy
  • 2,883
  • 1
  • 11
  • 21