burntheblobs Posted November 2, 2008 Share Posted November 2, 2008 I want to try and create a conditional that checks if anything is returned by a mysql query. For example something like this: $query = "SELECT School_Name FROM school WHERE schoolName='$school'"; $result = mysqli_query($cxn,$query) or die ("Couldn't execute query."); extract(mysqli_fetch_assoc($result)); if (extract(mysqli_fetch_assoc($result)) = "") { Do things } But it isn't working. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/131090-trying-to-use-conditionals-on-mysql-results/ Share on other sites More sharing options...
n3ightjay Posted November 2, 2008 Share Posted November 2, 2008 try $query = "SELECT School_Name FROM school WHERE schoolName='$school'"; $result = mysqli_query($cxn,$query) or die ("Couldn't execute query."); extract(mysqli_fetch_assoc($result)); if (extract(mysqli_fetch_assoc($result)) != 0) { Do things } Quote Link to comment https://forums.phpfreaks.com/topic/131090-trying-to-use-conditionals-on-mysql-results/#findComment-680598 Share on other sites More sharing options...
wildteen88 Posted November 2, 2008 Share Posted November 2, 2008 This is not the correct way. You should use mysql_num_rows as shown here Quote Link to comment https://forums.phpfreaks.com/topic/131090-trying-to-use-conditionals-on-mysql-results/#findComment-680601 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.