Results 1 to 2 of 2

Thread: if No results then post error

  1. #1
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default if No results then post error

    I am looking for a way to have it so if someone searches for something and it doesn't exist... It will say something like "We don't have it..."
    I am using a search thing i made which uses PHP and MySQL... When there are results it works but when there aren't results there isn't even an error...
    Once again I am using PHP and MySQL to make my site so I can't use ASP or other server scripts...
    Thanks in advance!
    Last edited by Rockonmetal; 04-20-2008 at 09:36 PM. Reason: just noticed, its my 500th post!

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Well, you can use mysql_num_rows, so try this:
    Code:
    if(mysql_num_rows($result) == 0){
    die('No results.');
    }
    If you want it to die, or you can do something like this:
    Code:
    if(mysql_num_rows($result) == 0){
    echo 'No results';
    } else {
    //while()
    }
    Jeremy | jfein.net

  3. The Following User Says Thank You to Nile For This Useful Post:

    Rockonmetal (04-20-2008)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •