What is the best way to add or display the number of items in a mysql table using php.
Because when I run this code the following error appears:% Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in H:\Web\root\index.php on line 89
$mysql_connection = mysql_connect($web_host, $web_user, $web_pass);
$mysql_connection_from_db = mysql_select_db($web_db);
$command_ = "SELECT COUNT('usr_id') FROM 'app_users'";
$mysql_query = mysql_query($command_);
$num = mysql_num_rows($mysql_query);
if(0 == $num) { $PESSOAS = 0; }
else{
while($row = mysql_fetch_assoc($mysql_query))
{
$PESSOAS = $PESSOAS + 1;
}
}
Line 89:
$num = mysql_num_rows($mysql_query);
The goal is for the user to click join and it adds any name plus an id in the table and when loading the page the php system shows how many items it has in that table, or in this case, $PESSOAS
, which determines the number of participants.