View Full Version : counting mysql ?
[Oli]
12-11-2006, 12:43 PM
pm'ed this to som1 but 'he/she' is offline now.
i need help :(
whats the mysql code to count how many things i have in my database ?
ex: i have a database called Folio with a table called content
in that table are my designs i posted.
now i want a code that gives me this;
There are ... designs
... would be how many designs are in there.
atm i got this;
<?
include("config.php");
$select = mysql_query("SELECT * FROM `content`");
$get = mysql_num_rows($select);
echo("There are $get designs");
?>
but i get this error:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/olivierp/public_html/Folio/count.php on line 5
There are designs
Thanks, oli
Whats the name of the variable you assigned the mysql_connect to? (e.g if it was $mysql your code would be:)
<?
include("config.php");
$select = mysql_query("SELECT * FROM `content`", $mysql);
$get = mysql_num_rows($select);
echo("There are $get designs");
?>
[Oli]
12-11-2006, 12:52 PM
Whats the name of the variable you assigned the mysql_connect to? (e.g if it was $mysql your code would be:)
<?
include("config.php");
$select = mysql_query("SELECT * FROM `content`", $mysql);
$get = mysql_num_rows($select);
echo("There are $get designs");
?>
I will check, and thanks for helping ;)
EDIT=
$connect = mysql_connect( ... and so on
so its $connect i asume ?
2ND EDIT:
with;
<?
include("config.php");
$select = mysql_query("SELECT * FROM `content`", $connect);
$get = mysql_num_rows($select);
echo("There are $get designs");
?>
i get same error:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/olivierp/public_html/Folio/count.php on line 5
There are designs
xRoyal15
12-11-2006, 01:52 PM
Make sure spellings are all correct... in my site i use:
$new = mysql_query("select * from users");
$new = mysql_num_rows($new);
And that counts how many members there are fine... yours looks the same as mine so its weird....
Jackboy
12-11-2006, 02:17 PM
;2527119']I will check, and thanks for helping ;)
EDIT=
$connect = mysql_connect( ... and so on
so its $connect i asume ?
2ND EDIT:
with;
<?
include("config.php");
$select = mysql_query("SELECT * FROM `content`", $connect);
$get = mysql_num_rows($select);
echo("There are $get designs");
?> i get same error:
You do not need the $connect bit.
what are the rows in ur content table?
Coz im thinking u MIGHT need to do an array...
Try this:
<?
include("config.php");
$selecter = mysql_query("SELECT * FROM `content`");
while ($select = mysql_fetch_array($selecter)){
$get = mysql_num_rows($select);
echo("There are $get designs");
}
?>
Tell me if it works ;)
[Oli]
12-11-2006, 02:35 PM
your codes dont work; i editted my code to this;
<?
include("config.php");
$select = mysql_query("SELECT * FROM `content`");
$array[]=@mysql_num_rows($select);
if (count($array)==0)
echo("There are no designs");
echo("There are $select designs");
?>
I dont get error now, but it doesnt show an ammount i just get
There are designs
Jackboy
12-11-2006, 03:17 PM
My one doesn't work :S ;o
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.