Leilin Peng Share: PHP MySQL Where Clause

  WHERE clause is used to filter records.

  WHERE clause

  WHERE clause is used to extract records that meet the specified criteria are.

  grammar

  SELECT column_name(s)

  FROM table_name

  WHERE column_name operator value

  To learn more about SQL, please visit our SQL tutorial.

  To get PHP to execute the statement above we must use mysqli_query () function. This function is used to send a query or command to the MySQL.

  Examples

  The following "Persons" table select instances from all rows FirstName = 'Peter' is:

  

  $con=mysqli_connect("localhost","username","password","database");

  // detect the connection

  if (mysqli_connect_errno())

  {

  echo "connection failed:" mysqli_connect_error ();.

  }

  $result = mysqli_query($con,"SELECT * FROM Persons

  WHERE FirstName='Peter'");

  while($row = mysqli_fetch_array($result))

  {

  echo $row['FirstName'] . " " . $row['LastName'];

  echo "
";

  }

  ?>

  Above will output:

  Peter Griffin

  View all PHP tutorial article: https://www.codercto.com/courses/l/5.html (edit: Leilin Peng Source: network intrusion deleted)

Guess you like

Origin www.cnblogs.com/linpeng1/p/11126821.html