0

I am having a problem on retrieving data from a database, the data is being fetched from two tables, named Employee (columns are id,first_name,last_name) and user(columns are user_type, username). When I execute the code I am getting this error:

Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, bool given in C:\xampp\htdocs\test\retrive_data.php on line 31

<?php

    include("connect2.php");

    $query="SELECT employee.id,employee.first_name,employee.last_name user.user_type, user.username FROM employee,user WHERE employee.id=user.imploy_id";
    $result=mysqli_query($conn,$query);
    ?>

    <!DOCTYPE html>
    <html lang="en">
    <head>
    </head>
    <body>
    <br>
    <table class="table table-bordered">
       <tr>
           <td>ID</td>
           <td>first_Name</td>
           <td>Last_name</td>
       <td>user_type</td>
       <td>username</td>
       <td>Edit</td>
       <td>Delete</td>
   </tr>
  <?php 

  while($row=mysqli_fetch_assoc($result))//
  {
          $userid=$row\['id'\];
          $firstname=$row\['first_name'\];
          $Lastname=$row\['last_name'\];
          $usertype=$row\['user_type'\];
          $username=$row\['username'\];
   ?>

   <tr>
         <td><?php echo $userid; ?></td>
         <td><?php echo $firstname; ?></td>
         <td><?php echo  $Lastname; ?></td>
         <td><?php echo  $usertype; ?></td>
         <td><?php echo $username; ?></td>
  </tr>
 <?php  
 }
 ?>

</table>
theduck
  • 2,589
  • 13
  • 17
  • 23
Dully90
  • 1
  • 1

1 Answers1

-1

not

$userid=$row\['id'\]; 

but

$userid=$row['id'];

missing details about query and how you get $result

Josef
  • 13
  • 5