This is a MySQL function that allows you to find out how many rows there are in a specific table.
It requires only one parameter which tells it whats the MySQL query.
I found it extremely useful when making a flash and MySQL and PHP driven site.
PHP:
-
<?php
-
$link =
mysql_connect("localhost",
"root",
"");
//conect to db server
-
-
-
$result =
mysql_query("SELECT * FROM projects",
$link);
//select the table
-
-
-
echo "total_rows=$num_rows";
//echo number of rows
-
-
?>
i hope you find it just as useful to you just like when i first found it.
However if you are looking for executing queries fast I would use:
PHP:
-
<?php
-
$link =
mysql_connect("localhost",
"root",
"");
//conect to db server
-
-
$result =
mysql_query("SELECT COUNT(*) FROM projects",
$link);
//select the table
-
echo "total_rows=$result";
//echo number of rows
-
?>
Share and Enjoy:
These icons link to social bookmarking sites where readers can share and discover new web pages.
This entry was posted
on Sunday, July 29th, 2007 at 3:19 pm and is filed under PHP Coding.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.