Jump to content

Recommended Posts

How do i achieve this? I've been planning out a new bit for a page on my site, and i know that currently, if any of my requests come back blank ie

 

"SELECT from table WHERE venue='o2 arena' "

 

And there IS NO 'o2 arena' in the database, instead of displaying nought, it displays some error messages.

 

In the new bit for my site, at first most of the time it will coming back empty!

 

So how do i do an, IF EMPTY { } else {}

 

?? :os

You can count the number of result after the query like that :

 

$sql = "SELECT from table WHERE venue='o2 arena'";
$result = mysql_query($sql);
if (!$result) {
    die('Invalid query: '.$sql.' -- '.mysql_error());
}

if (mysql_num_rows($result) > 0)
{
/* display your data */
} else {
echo "No results.";
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.