Forum Moderators: coopster
where attend field is supposed to hold 'A' or 'P' corresponding to every date.
Now i find it difficult when i want to find out the attendance percentage for each subject per student.
Also there are many redundant entries which is making it slower,such as for each student there are 6 subjects
Can u suggest me something to improve upon this so that i can make it work.I dont mind changing the table structure or adding additional tables.
(Btw the first 3 fields are imported from 3 tables namely allotment,subject and student. where allotment stores which faculty takes which subject which in turn corresponds to a list of students).
Any help will be appreciated. Thanks.
you could do a few things
first read about Optimization [dev.mysql.com]
also, couldn't you first average the results of the students six fields and load the result in a new table
then use that single result in your final query?
we need more info on table structure and your scripts logic
Now if want to find out the attendance percentage=(Classes attended/Total no of classes) for any one(lets say 050903123 in subject ELE123),what logic can i use here?
$sql=mysql_query("SELECT
count(attend)
From
FROM
attendance
WHERE
Studentroll='$studentroll'
AND
SubCode='$subcode' ");
$num=mysql_result($sql,0);
echo"$num<br>";
$sql2=mysql_query("SELECT
count(subcode)
From
FROM
attendance
WHERE
Studentroll='$studentroll'
AND
SubCode='$subcode' ");
$num2=mysql_result($sql2,0);
echo"$num2<br>";
$percent=($num2/$num)/100;
echo"$percent<p>";