Jump to content

Trying to use conditionals on mysql results


burntheblobs

Recommended Posts

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?

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
}

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.