I am developing an attendance view page using from date and to date and register number of a student. In this page, I am dealing with 3 tables. Most important one is manage_attendance. I want to show details from this table according to the constraints
the other two are
subjects
student_info
I want to show the content in the following format.
period1 2 3 4 5 6 7 8
2016-02-20 cs1101 EM1 cs1102M ...........................
2016-02-21 cs1101 EM1 cs1102M ...........................
my php code
<?php
$fromdate='2016-02-20';
$todate='2016-02-22';
$st_regno='1214301';
$resa=mysql_query("select st_id from student_info where st_regno='$st_regno'");// select student id corresponding to registration number
$rowa=mysql_fetch_row($resa);
/***********main part************/
$resb=mysql_query("SELECT *
FROM manage_attendance
WHERE st_id = '$rowa[0]'
AND DATE
BETWEEN '$fromdate'
AND '$todate'
ORDER BY period");
while($rowb=mysql_fetch_assoc($resb)){
echo $rowb['date']." ".$rowb['period'];
$id=$rowb['subject'];
echo $id;
$resc=mysql_query("select subjects from subjects where `id` = '$id'");//select subject name from subject table with id
$rowc=mysql_fetch_assoc($resc);
echo $rowc['subjects'];
?>
/**************************/
database structure
manage_attendance
CREATE TABLE IF NOT EXISTS `manage_attendance` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`st_id` int(11) NOT NULL,
`date` date NOT NULL,
`sem_id` varchar(11) NOT NULL,
`period` int(11) NOT NULL,
`subject` varchar(30) NOT NULL,
`status` tinyint(1) NOT NULL,
PRIMARY KEY (`id`)
)
studeny_info
CREATE TABLE IF NOT EXISTS `student_info` (
`st_id` int(50) NOT NULL AUTO_INCREMENT,
`st_name` varchar(50) NOT NULL,
`st_regno` int(50) NOT NULL,
`stparent_no` bigint(20) NOT NULL,
`roll_no` int(11) NOT NULL,
`sem_id` int(20) NOT NULL,
PRIMARY KEY (`st_id`)
)
subjects
CREATE TABLE IF NOT EXISTS `subjects` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`subjects` varchar(50) NOT NULL,
`sem_id` int(5) NOT NULL,
PRIMARY KEY (`id`)
)
Please help me to do this...Please come in chat if you have any doubts...Thankyou...