ok, if you are reading this short tutorial guide, i am going to show you how you can get the number of totoal rows there are in a table.
for example, lets say i have a table in mysql database called users and i want to know the total number of user in this table, I am i luck because i have a unique field called user_id. each user in my table has a user_id number so i can use this field to count the number to total users i have in my table.
so i want mysql query to do the counting for me, well, its simple just use this query with your sql script:
Code:<?
$sql = "select count(user_id) from users";
?>
you can take this query even further, let say i want to query on all the user_id in my users table that have an active account. I have a field called "user_status" and it could either be "active" or "non-active" so i would use this query to get only the users which are "active":
Code:<?
$sql = "select count(user_id) from users where user_status = 'active' ";
?>
hope this helps. let me know if it does.
i real life example
Code:$sql2 = "select count(user_id) from users where user_status='active' and category='registered' ";
$result2 = mysql_query($sql2 ,$db);
$row2 = mysql_fetch_row($result2);
$count_users = $row2[0];
echo "I have this many registered users with active account: $count_users";