Call us Toll-Free:
1-800-218-1525
Live ChatEmail us

 Sponsors

Outputs no of records in a table

Code Wizard, 12-30-2006

Outputs the number of records in a table

<?php

$db = mysql_connect("localhost","username","password");
mysql_select_db("database",$db);
$result = mysql_query("SELECT count(*) AS num FROM table",$db);
$num = mysql_result($result,0,"num");

if ($num == 1){
// if number of entries is more than 1
printf("<font color=red>%s</font>",$num); //prints number
}
// if number of entries is less than 1
else {
printf("<font color=red>%s</font>",$num); //print number
}

?>
Enjoyed this post?

Subscribe Now to receive new posts via Email as soon as they come out.

 Comments
Post your comments












Note: No link spamming! If your message contains link/s, it will NOT be published on the site before manually approved by one of our moderators.



About Us  |  Contact us  |  Privacy Policy  |  Terms & Conditions