quick question (I hope)
when doing a query and there are no results returned I want to print out a message saying so but I am not sure how to do that with my current code.
this is just a snipette of my code and I am getting no errors
if(empty($religion)) {
$result = mysql_query("SELECT user.userID, user.gender, user.genderPref, user.city, user.state, photos.photo_1,
CURDATE(), (YEAR(CURDATE())-YEAR(birth_date)) - (RIGHT(CURDATE(),5)<RIGHT(birth_date,5)) AS age
FROM user
LEFT JOIN photos
ON user.userID = photos.userID
LEFT JOIN about_me
ON user.userID = about_me.userID
LEFT JOIN bkgd
ON user.userID = bkgd.userID
WHERE zip IN (". $zips_in_range .") AND user.bd_year <= $year1 AND user.bd_year >= $year2 AND genderPref = $gender AND gender = $genderPref AND about_me.smoking = $smoke
ORDER by user.userID")or die('query 3 failed'); }
else {
$result = mysql_query("SELECT user.userID, user.gender, user.genderPref, user.city, user.state, photos.photo_1,
CURDATE(), (YEAR(CURDATE())-YEAR(birth_date)) - (RIGHT(CURDATE(),5)<RIGHT(birth_date,5)) AS age
FROM user
LEFT JOIN photos
ON user.userID = photos.userID
LEFT JOIN about_me
ON user.userID = about_me.userID
LEFT JOIN bkgd
ON user.userID = bkgd.userID
WHERE zip IN (". $zips_in_range .") AND user.bd_year <= $year1 AND user.bd_year >= $year2 AND user.gender = $genderPref AND user.genderPref = $gender AND about_me.smoking = $smoke AND bkgd.relg = $religion
ORDER by user.userID")or die('query 4 failed'); }}
}
if (empty($result)){
echo "Sorry No Results found, please try again with a boarder search area."; }
else { ...
I have also tried this but always get the "No results" message
if ($result = "null"){
echo "Sorry No Results found, please try again with a boarder search
else { ...
also tried this but get no message
if (!$result){
echo "Sorry No Results found, please try again with a boarder search
else { ...