I want to select firsname, mobileno, city,employee-name ect.. by email or by unique code , because email will differ user by user and the thing I'm using Email as login, so if any user input an email or Code I want to Echo him/his details.
Consider My database Has:
id firstname MobileNo City State Email Code
1 xxxxx 0000000 Arkansas California YYY@xx.com ABCDE
So I'm uses the query but it doesn't work
$sql = mysql_query("SELECT firstname,Mobileno,City,Employee-Name FROM `clients` WHERE email = '$email' AND code = '$code'");
So Please Help Me Out, Thanks In Advance.
Your question title says it all. Use OR
instead of AND
:
$sql = mysql_query("SELECT firstname,Mobileno,City,Employee-Name
FROM `clients`
WHERE email = '$email'
OR code = '$code'")
OR
means either email='$email'
or code='$code'
.
If you use AND
both conditions should be satisfied.
as i know you want use one of email or code?
i think you should use this:
$sql = mysql_query("SELECT firstname,Mobileno,City,Employee-Name FROM `clients` WHERE email = '$email' OR code = '$code'");
Use this code with OR
condition.
$sql = mysql_query("SELECT firstname,Mobileno,City,Employee-Name
FROM `clients`
WHERE email = '.$email.'
OR code = '.$code.'")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.