Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2011
    Posts
    16

    Unanswered: PHP: how do you get the number of rows returned by a query?

    I want to know how many rows are in a result. I know you can use mysql_fetch_array iteratively, but can you get the size directly?

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    try boning up on the PHP manual
    especially
    PHP: Mysql - Manual
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Apr 2005
    Posts
    29
    Here is a very basic way.
    PHP Code:
    <?php

    $link 
    mysql_connect("localhost""mysql_user""mysql_password");
    mysql_select_db("database"$link);

    $result mysql_query("SELECT * FROM tbl1"$link);
    $num_rows mysql_num_rows($result);

    echo 
    "$num_rows Rows\n";

    ?>
    Web Database Software - Build your own php mysql database.

Posting Permissions

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