Mysql WHERE Clause

We have seen the SQL SELECT command to fetch data from a MySQL table. We can use a conditional clause called the WHERE Clause to filter out the results. Using this WHERE clause, we can specify selection criteria to select the required records from a table.

First, you can need database connection in PHP

Code

<table>
  <thead>
    <tr>
      <th>Email</th>
      <th>Password</th>
      <th>Mobile</th>
      <th>Date</th>
    </tr>
  </thead>

  <tbody>
      <?php
      $sql = "SELECT * FROM users WHERE user_type = '1' "; 
      $result = mysqli_query($con,$sql);
      while($row = mysqli_fetch_assoc($result))
      {
      ?>
      <tr>
            <td><?=$row['email']?></td>
            <td><?=$row['password']?></td>
            <td><?=$row['mobile']?></td>
            <td><?=$row['create_date']?></td>
      </tr>
    <?php
      }
    ?>
  </tbody>
</table>

Leave a Reply

Your email address will not be published. Required fields are marked *