[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.
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.
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.
Re: Num records in table (MySQL database manipulation with php)
Code:
SELECT COUNT(*) FROM tablename
As simple as it gets.
Re: Num records in table (MySQL database manipulation with php)