#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    3
    Rep Power
    0
    What's the mysql code for counting the records in a table. I now have a php3 file with connect and select (it's all OK)

    $records = mysql_numrows(mysql_query(SELECT * FROM penpals));

    But this doesn't display the number of records in table "penpals". How could I do this?
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    Your function is wrong. The function is:

    mysql_num_rows()

    Notice the additional underscore?

    Also, you need to place quotes around your query:

    $records = mysql_num_rows(mysql_query("SELECT * FROM penpals"));

    The following results in a quicker query and less memory usage:

    list($records)=mysql_fetch_row(mysql_query("select count(*) from penpals"));

    HTH
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    3
    Rep Power
    0
    And what should be the whole php3 file with only a counter in it??? It doesn't work!
  6. #4
  7. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    do you mean:

    print $result;

    ???

Similar Threads

  1. Replies: 6
    Last Post: July 25th, 2002, 07:19 PM
  2. Displaying records per page
    By le_world in forum PHP Development
    Replies: 3
    Last Post: July 11th, 2002, 01:01 AM
  3. update multiple records from one page
    By dahoule in forum PHP Development
    Replies: 2
    Last Post: January 28th, 2002, 12:55 PM
  4. Displaying 10 records per page
    By raghuram in forum PHP Development
    Replies: 1
    Last Post: June 10th, 2000, 06:38 AM
  5. Again: Displaying 10 records per page
    By raghuram in forum PHP Development
    Replies: 1
    Last Post: June 10th, 2000, 02:44 AM

IMN logo majestic logo threadwatch logo seochat tools logo