Forum Moderators: coopster
$sql = "SELECT COUNT(gender) as totalrows FROM subscribers WHERE gender=Male";
$result = mysql_query($sql, $conn);
echo ("There are $result male subscribers.")
but nothing is printing. Do I need to do something with "$i" and "++"? If you are selecting a specific record and not the entire row is the result still an array?
RS
This should do the trick:
$sql = "SELECT COUNT(gender) as totalrows FROM subscribers WHERE gender=Male";
$results = mysql_query($sql, $conn);
$totalrows = mysql_result($results,0,"totalrows");
echo ("There are $totalrows male subscribers.")
or you could use the 'mysql_num_rows' function:
$sql = "SELECT * as totalrows FROM subscribers WHERE gender=Male";
$results = mysql_query($sql, $conn);
$totalrows = mysql_num_rows($results);
echo ("There are $totalrows male subscribers.")
Hope this helps.