如何以格式显示出席表格内容

时间:2016-03-03 07:47:41

标签: php mysql view

我正在使用日期和日期开发出勤视图页面并注册学生编号。在这个页面中,我正在处理3个表。最重要的一个是manage_attendance。我想根据约束

显示此表中的详细信息

manage_attendance manage_attendance

另外两个是
受试者

subjects

student_info

enter image description here

我想以下列格式显示内容。

                  period1      2        3      4     5    6    7     8
2016-02-20        cs1101 EM1  cs1102M      ...........................
2016-02-21        cs1101 EM1  cs1102M      ...........................  

我的PHP代码

 <?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'];
 ?>
 /**************************/

数据库结构

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`)
 )

受试者

 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`)
 )

请帮我这样做...如果您有任何疑问,请进来聊聊......谢谢......

0 个答案:

没有答案