-
SQL finding record count
Could anyone tell me how I would find out how many records are in my table using this code:
PHP Code:
<?php
$query = "SELECT COUNT(*) FROM table";
$numrows = mysql_query($query) or die("Select Failed!");
$numrow = mysql_fetch_array($numrows);
echo $numrow;
?>
All it gives is "Array" as the output.
Thank for any help
-
try
PHP Code:
echo $numrow[0];
-
Code:
<?php
$query = "SELECT * FROM table";
$result = mysql_query($query) or die("Select Failed!");
$numrows = mysql_num_rows($result);
echo $numrows;
?>
mysql_num_rows() is the function that will return how many records are in a query result.
Edit: Editted to change the SQL statement to make my code make sense.
-
-
Nevermind. I didn't even look at your SQL statement to see that you were using COUNT(). Nevermind me.
-