Hi I am new to PHP and I would like to know how to pass a count() to a table. here is my sql command:$sql = "SELECT Dept,COUNT(Dept) FROM students group by Dept"; I can get it to do a count of all my data but I need it to be displayed in a table and a count by Dept. any help will be appresiated. Please email Me: shaun.fisher@virtuality.co.za Thanx Shaun Fisher
use 'count(Dept) as cnt' and continue asif 'cnt' is a normal column.
Vincent you say I should do something like ...$result = mysql_query("select Dept, cnt from students group by dept",$db); please forgive me but I am very new to this.
if (!$result = mysql_query("select Dept, count(Dept) as cnt from students group by dept",$db)) { echo 'SQL FAILED:'.mysql_error(); } else { while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo $row['cnt']; }; };