SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist JordashTalon's Avatar
    Join Date
    Dec 2008
    Posts
    505
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to find out how many Rows are in a Database

    How would you detect how many rows are in a MySQL table which meet a certain criteria:

    Pseudo Code:

    $rowCount=How Many Rows in Table WHERE published='yes';

    Thanks

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php
    $sSQL 
    "SELECT COUNT(id) AS numRows FROM table WHERE foo = 'bar'";
    $rQuery mysql_query($sSQL);
    $aResult mysql_fetch_assoc($rQuery);
    printf(
        
    'The query "%s" resulted in %s rows.',
        
    $sSQL,
        
    $aResult['numRows']
    );
    ?>
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    SitePoint Evangelist JordashTalon's Avatar
    Join Date
    Dec 2008
    Posts
    505
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks.


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
  •