php - Count MySql database rows with field value = '1' -
i'm trying count number of rows in database field 'level' equal '1'. have set count fields, see code below.
$result = mysql_query("select count(1) username"); $row = mysql_fetch_array($result); $total = $row[0];
now adapt select field level = 1 in database.
i have database connection setup , working fine.
i did try code gettign nowhere.
$admins = mysql_query("select count(1) level='1'"); $totaladmins = mysql_fetch_array($admins); $totaladmins = $admins[0];
once number of rows have been calculated displayed users through following code
<h4><?php echo $total?> users registered</h4>
any supper appreciated.
there problem you're having because forgot include table select from. instead of:
select count(1) level='1';
your query should be:
select count(1) username level='1';
hopefully fixes problem. :)
Comments
Post a Comment