does anybody know a mysql query that i can use in my php document that will return the number of rows their are in a table?

thanks, i cant find it in the MySQL mannual

Recommended Answers

All 5 Replies

how whould i use that to return the result in php. do i just use

$result = mysql_num_rows(info);

or is there more to it

<?php

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

$result = mysql_query("SELECT * FROM table1", $link);
$num_rows = mysql_num_rows($result);

echo "$num_rows Rows";

?>

Actually, not to step on Stymiee's feet but there is a a less memory intensive way to do it.

SELECT COUNT(*) FROM table_name

The result will be the num rows

Nice tutorial....Above two ways are helpful...................

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.