Jump to content

Display total records


erme

Recommended Posts

$query = "SELECT * FROM Table WHERE County = 'Essex' ORDER BY id DESC";
$result = mysql_query($query)or trigger_error("MySQL Error With Query 1", E_USER_WARNING);
$num = mysql_num_rows($result);


echo "<pre>\tThere are " . number_format($num) . " records in the County 'Essex'.\n</pre>";

 

 

mysql_num_rows

Im not stalking you andy i swear :P.

But you can use a native mysql function to count the number of rows:

SELECT count(*) FROM `table` WHERE `County`='Essex'

 

eg:

<?php

// Connect

$query = "SELECT count(*) FROM `table` WHERE `County`='Essex'";
$result = mysql_query($query) or die(mysql_error());
$number = mysql_result($result,0,0);

echo($number);

?>

 

-CB-

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.