COUNT data from database

i have a database that looks like this
stud_no name year_level
1 abc Grade_1
2 def Grade_1
3 ghi Grade_2
4 jkl Grade_3
5 mno Grade_3

when i make a query i want it to look like this
Grade 1 Grade 2 Grade 3
2 1 2

[php]

<?php include('connectdb.php'); $result = mysql_query("SELECT COUNT(level) FROM students") or die(mysql_error()); echo ""; echo ""; echo ""; while($row = mysql_fetch_array( $slots )) { // echo out the contents of each row into a table echo ""; echo ''; echo ''; echo ''; echo ""; } ?>

[/php]

with this code what happens is it doesnt show any results
please help my head hurts
thx

Slots Taken (Max = 40)
Grade 1 Grade 2 Grade 3
' . $row['Grade_1'] . '' . $row['Grade_2'] . '' . $row['Grade_3'] . '

sorry i posted the wrong code
[php]

Untitled Document <?php include('connectdb.php'); $result = mysql_query("SELECT COUNT(level) FROM students") or die(mysql_error()); echo ""; echo ""; echo ""; while($row = mysql_fetch_array( $result )) { // echo out the contents of each row into a table echo ""; echo ''; echo ''; echo ''; echo ""; } ?>

[/php]

Slots Taken (Max = 40)
Grade 1 Grade 2 Grade 3
' . $row['Grade_1'] . '' . $row['Grade_2'] . '' . $row['Grade_3'] . '

It doesn’t show any results because you are using COUNT in your mysql query. COUNT is used to count results so will only return a value.

Sponsor our Newsletter | Privacy Policy | Terms of Service