NameSilo

Mysql_num_rows()

Spaceship Spaceship
Watch
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 extreemly useful when making a flash and mysql and php driven site.

PHP:
<?php
$link = mysql_connect("localhost", "root", "");//conect to db server
mysql_select_db("haco", $link);//select db

$result = mysql_query("SELECT * FROM projects", $link); //select the table
$num_rows = mysql_num_rows($result); //set variable

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
mysql_select_db("haco", $link);//select db

$result = mysql_query("SELECT COUNT(*) FROM projects", $link); //select the table

echo "total_rows=$result"; //echo number of rows

?>

That was a suggestion by NuPagady
 
Last edited:
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
.US domains.US domains
Yes, that would work. However, I think "SELECT COUNT(*) FROM projects" query would work faster.
 
0
•••
thanks for the suggestion. I will add it too.
 
0
•••
Got to agree :)
 
0
•••
Thnx for the helpfull information, i used to code php and that stuff before, but i havent done so in about 1.5 years :(
 
0
•••
Appraise.net

We're social

Domain Recover
DomainEasy — Live Options
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back