Let say that we have the following query:
SELECT DISTINCT COUNT(`users_id`) FROM `users_table`;
this query will return the number of the users from a table. I need to pass this value to a PHP variable. I'm using this:
$sql_result = mysql_query($the_query_from_above) or die(mysql_error());
if($sql_result)
{
$nr_of_users = mysql_fetch_array($sql_result);
}
else
{
$nr_of_users = 0;
}
please correct my code where you think is necessary.
Which is the best approach. How do you recommend to do this ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…