If you want to filter data(records) in the record set based on two or more conditions then use AND operator that filter result.
PHP MySQL AND Operator Example:
If you want to filter data(records) in the record set based on two or more conditions then use AND operator that filter result, only those records contain by the record set that full fill these conditions in the given conditions.
Example:
<?php $connection = mysql_connect("localhost","root","root"); if (!$connection) { die('PHP Mysql database connection could not connect : ' . mysql_error()); } else{ $db_name = "php_mysql"; mysql_select_db($db_name, $connection); $sql = "select * from user where user_name='Brijesh' and user_email='brijesh@gmail.com';"; $records = mysql_query($sql, $connection); while($rows = mysql_fetch_array($records)){ echo "User Id : " . $rows['user_id'] . "<br />"; echo "User Name : " . $rows['user_name'] . "<br />"; echo "User Email : " . $rows['user_email'] . "<br />"; echo "User Address : " . $rows['user_address'] . "<br /><br /><br />"; } } mysql_close($connection); ?>
The database user table records is:
In this example the executed mysql query fetch those record that fulfill these two conditions.
Output:
User Id : 2 User Name : Brijesh User Email : brijesh@gmail.com User Address : Delhi
[ 0 ] Comments