Results 1 to 5 of 5

Thread: [resolved]Num records in table (MySQL database manipulation with php)

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2005
    Posts
    74

    Resolved [resolved]Num records in table (MySQL database manipulation with php)

    Is there a way to get the number of entries (records, lines) in a table. I've been doing it a very ineffeciant way and I know I can't keep doing it. I've called Select (one column) from table then using msql_numrows on the result. There's got to be a better way. Also, if I can select the last entry it can tell me because it has a row with autoIncrements.
    Last edited by vagabon; Oct 11th, 2006 at 09:17 AM.

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Num records in table (MySQL database manipulation with php)

    Use the COUNT sql function.

    And no, selecting the last entry and checking its ID does not give you a reliable count. For one, the ID could wrap around eventually. More importantly, it would still count deleted rows.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2005
    Posts
    74

    Re: Num records in table (MySQL database manipulation with php)

    Whats the exact name of the function? I looked up count but that didn't seem as if it would work.

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Num records in table (MySQL database manipulation with php)

    Code:
    SELECT COUNT(*) FROM tablename
    As simple as it gets.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Oct 2005
    Posts
    74

    Re: Num records in table (MySQL database manipulation with php)

    Okay, thank you.

Posting Permissions

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



Click Here to Expand Forum to Full Width