I want to develop application using PHP. One module in this application displays attendance of students under particular teacher, between given two dates.
The structure of tables in database -
1. student_info(Roll_No, Teacher_Id, First_Name, Last_Name)
Present stores '1' if student is present on that date and '0' if absent.
If user selected two dates then attendance of students between those dates must be displayed in table.
I want to display result in the form
Roll No First Name Last Name Conducted lectures Attended Lectures
1 ABC ABC 4 2
2 XYZ XYZ 4 3
I tried to do that by first obtaining the set of students under particular Teacher from "student_info" table. Then for each student in this set I fired following query
$Query=SELECT sum( attendance_info.Present ) , count( attendance_info.Present) FROM attendance_info WHERE attendance_info.Teacher_Id ='20' AND attendance_info.Roll_No ='1' AND Date BETWEEN '2011-03-09' AND '2011-03-15'; $view_attendance = mysql_query($query1, $database) or die(mysql_error()); $row_view_attendance = mysql_fetch_assoc($view_attendance); echo $row_view_attendance['sum( attendance_info.Present )']; echo $row_view_attendance['count( attendance_info.Present )'];
When I run this query in query analyzer it worked. But I'm not getting it with PHP.
Plz help me..