亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

PHP where statement

PHP MySQL Where clause

The WHERE clause is used to filter records.

WHERE clause

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

Syntax

SELECT column_name(s) FROM table_name

WHERE column_name operator value

To select data matching the specified conditions, please add to the SELECT statement WHERE clause.

The following operators can be used with the WHERE clause:

QQ圖片20161010090820.png

In order for PHP to execute the above statement, we must use mysqli_query() function. This function is used to send a query or command to the MySQL connection.

Example

The following example will select all rows with FirstName='Peter' from the "Persons" table:

<?php
$con=mysqli_connect("localhost","username","password","database");
// 檢測(cè)連接
if (mysqli_connect_errno())
{
         echo "連接失敗: " . 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 "<br>";
}
?>

The above code will output:

Peter Griffin


Continuing Learning
||
<?php $con=mysqli_connect("localhost","username","password","database"); // 檢測(cè)連接 if (mysqli_connect_errno()) { echo "連接失敗: " . 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 "<br>"; } ?>
submitReset Code