dousikuai5417 2016-03-03 07:47 采纳率: 0%
浏览 121

如何以格式显示考勤表内容

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

manage_attendance manage_attendance

the other two are
subjects

subjects

student_info

enter image description here

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...

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 我的数据无法存进链表里
    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
    • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
    • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
    • ¥15 如何在炒股软件中,爬到我想看的日k线
    • ¥15 seatunnel 怎么配置Elasticsearch
    • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
    • ¥15 (标签-MATLAB|关键词-多址)
    • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
    • ¥500 52810做蓝牙接受端