Use WHERE clause to filter records in PHP

Description

The following code shows how to use WHERE clause to filter records.

Example


<?php//  w  ww  .  ja v  a 2  s  .  c om
    $con=mysqli_connect("example.com","root","","test");
    // Check connection
    if (mysqli_connect_errno()) {
      echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }

    $result = mysqli_query($con,"SELECT * FROM employee");

    while($row = mysqli_fetch_array($result)) {
      echo $row['id'] . " " . $row['Name'];
      echo "<br>";
    }
?>




















Home »
  PHP Tutorial »
    MySQL »




MySQLi
MySQLi Object Oriented