[thelist] sorting averages by using PHP

Murat Tutumlu tutumlum at yahoo.com
Fri Mar 25 01:43:45 CST 2005

Hi everybody,

I have a table which named as Studentmarks1 with
"Student_no, lesson, class, V1, V2, F1, V3, V4, F2"
"V1, V2, F1, V3, V4, F2" are numbers over 100. I
printed averages of classes and it is sorting by class
name as shown in code below.
My problem is sorting by averages. I tried, but I
Any suggestion?
Thanks in advance..

Here is my code.
include "config.php";
$result = mysql_query("SELECT * FROM Studentmarks1
group by Class ",$db);
$myrow = mysql_fetch_array($result);
<form action="" method="post" name="form1"
  <select name="exam">
    <option value="">Choose an exam</option>
    <option value="V1">Visa 1</option>
    <option value="V2">Visa 2</option>
    <option value="F1">Final 1</option>
    <option value="V3">Visa 3</option>
    <option value="V4">Visa 4</option>
    <option value="F2">Final 2</option>
<input type="submit" name="Submit" value="Show">

do { 
$sql = mysql_query("SELECT AVG($exam) FROM
studentmarks1 WHERE class='$myrow[Class]'",$db); 
$aver = mysql_fetch_array($sql); 
$aver[0] = number_format ($aver[0], 2);

echo "$myrow[Class] : $aver[0]<br>";

while ($myrow = mysql_fetch_array($result));


Do you Yahoo!? 
Make Yahoo! your home page 

More information about the thelist mailing list