SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict cranjled's Avatar
    Join Date
    Apr 2004
    Location
    ny
    Posts
    382
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question if ($result->EOF)

    Can I only use this snip of code if in a class?
    Code:
    if ($result->EOF) {
            return false;
        }
    I have a procedural bit of code that returns a $result from the database successfully. But if no rows are returned, i'd prefer to show a status message instead of just leaving whitespace. Am I going about it wrong?

    I tested $result for true and false, but it always comes back true...even if no rows were found. Frustrating...

    Thanks,

    Cranjled

  2. #2
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    Parry Sound, ON
    Posts
    725
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    if(mysql_num_rows($result) < 1) {
    return 
    false;


  3. #3

    Join Date
    Oct 2003
    Location
    €uroLand
    Posts
    1,340
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Without knowing more about the class you are using its impossible to say whether there is a method to determine how many results were returned. If the class does not offer such a method you would either need to extend it or use the plain MySQL functions as HardCoded indicated.


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
  •