Jump to content

select statements in php mysql


kadamsurekha

Recommended Posts

hello friends!

  i have the table with fields:-

  ID,username,friendname,status

 

where status can be 1 or 2

 

now i want the query to execute such that it retrieves the data where the string passed can be either in username or in friendname with status 2 only.

 

i hav written the code in php file as follows:-

 

$username=$_POST['emailid'];

$result = mysql_query("SELECT username,friendname FROM friendlist where username='$username' or friendname='$username' and status=2");

 

after execution i get records from the table where $username exists in username or friendname field but with any status.

 

i want records where status is only 2 and $username exists in username or friendname field.

 

 

thx n regards

Link to comment
https://forums.phpfreaks.com/topic/44491-select-statements-in-php-mysql/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.