|
-
Jan 13th, 2004, 06:55 AM
#1
Thread Starter
Ex-Super Mod'rater
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
When your thread has been resolved please edit the original post in the thread (  )
and amend "-[RESOLVED]-" to the end of the title and change the icon to  , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

-
Jan 13th, 2004, 09:18 AM
#2
Frenzied Member
try
PHP Code:
echo $numrow[0];
-
Jan 13th, 2004, 09:28 AM
#3
Stuck in the 80s
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.
-
Jan 13th, 2004, 09:28 AM
#4
Thread Starter
Ex-Super Mod'rater
When your thread has been resolved please edit the original post in the thread (  )
and amend "-[RESOLVED]-" to the end of the title and change the icon to  , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

-
Jan 13th, 2004, 09:29 AM
#5
Stuck in the 80s
Nevermind. I didn't even look at your SQL statement to see that you were using COUNT(). Nevermind me.
-
Jan 13th, 2004, 09:30 AM
#6
Thread Starter
Ex-Super Mod'rater
When your thread has been resolved please edit the original post in the thread (  )
and amend "-[RESOLVED]-" to the end of the title and change the icon to  , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|