SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict Phil-man's Avatar
    Join Date
    Nov 2000
    Posts
    291
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This seems like it should be REALLY easy, but I don't know how to do it. If I use PHP to query a MySQL database, how do I determine if there are no matches? I tried

    if (!$result)...

    etc., but that only seems to work if the query itself fails, not if there are no matches. Thanks in advance!

  2. #2
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just grab the values from one of the fields using a while loop, and check one of the variables...

    if ($documentid < "1") {
    stuff
    }


  3. #3
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Uh? or just use:

    if(mysql_num_rows($result) > 0) {
    //do something
    }
    else {
    print "No records found!";
    }
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


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
  •