PHP – MySQL – Filter Results

Statement:

SELECT column_name(s)
FROM table_name
WHERE column_name operator value

<?php
// Create connection
// Statement: mysqli_connect(host,lucedigi_user,password,dbname)
// NOTICE: se lo script è installato nello stesso server del Data Base, host->localhost
$con=mysqli_connect("localhost","lucedigi_user","mypassword","lucedigi_testphp");

// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

// Filter records START
$result = mysqli_query($con,"SELECT * FROM Persons
WHERE FirstName='Peter'");

while($row = mysqli_fetch_array($result))
  {
  echo $row['FirstName'] . " " . $row['LastName'];
  echo "<br>";
  }
// Filter records END

mysqli_close($con); 
echo "Great! Connection Closed!"; 
?>

phpMyAdmin

mysql-0004

The result:

Peter Griffin