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? 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 } 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 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
Archived
This topic is now archived and is closed to further replies.