003.
<head>
004.
<meta http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
/>
005.
<link href=
"style.css"
rel=
"stylesheet"
type=
"text/css"
/>
006.
<style type=
"text/css"
>
007.
<!--
008.
.tree {
009.
font-family: Arial, Helvetica, sans-serif; font-size: 9;
010.
border: 1px solid black;
011.
}
012.
.tree th {
013.
border: 1px solid #FFFFFF;
014.
}
015.
.tree td {
016.
border: 1px solid #FFFFFF;
017.
}
018.
.no{ width : 100px; text-align : center;}
019.
.highlight{ background-color : #ffccaa; }
020.
.style2 {
021.
color: #FFFFFF;
022.
font-size: 11px;
023.
}
024.
.style3 {color: #FFFF33; font-size: 11px;}
025.
.style5 {color: #FF99CC}
026.
.style7 {color: #00FF33}
027.
.style9 {color: #FF9933}
028.
.style10 {color: #00FFCC}
029.
.style11 {color: #FFFFCC}
030.
.style13 {color: #999933}
031.
-->
032.
.no{ width : 100px; text-align : center;}
033.
.highlight{ background-color : #99aaff; font-size: 11px; }
034.
.title{ text-align : center;}
035.
</style>
036.
</head>
037.
038.
<body >
039.
<div
class
=
"container"
>
040.
<div
class
=
"row"
>
041.
042.
<form name=
"form1"
method=
"post"
action=
"taraStd.php"
>
043.
<table
class
=
"table table-striped"
border=
"0"
>
044.
<tr>
045.
<td colspan=
"4"
>
046.
<a style=
"bottom:left;"
href=
"taraStd.php"
type=
"button"
class
=
"btn btn-info"
><span
class
=
"glyphicon glyphicon-refresh"
></span> Refresh Data</a>
047.
</td>
048.
<td colspan=
"4"
align=
"right"
>
049.
ค้นหาจากรหัสนักเรียน :
050.
<input type=
"text"
align=
"right"
placeholder=
"ค้นหาตารางเรียนนักเรียน"
value=
"<?=$_POST["
txtKeyword
"];?>"
name=
"txtKeyword"
/>
051.
<input type=
"submit"
name=
"submit"
value=
"ค้นหา"
>
052.
</td>
053.
</tr>
054.
</table>
055.
<div
class
=
"table-responsive"
>
056.
<table width=
"100%"
border=
"0"
cellpadding=
"0"
cellspacing=
"0"
class
=
"tree"
align=
"center"
>
057.
<tr>
058.
<td width=
"7%"
valign=
"top"
>
059.
<table width=
"100%"
border=
"1"
cellspacing=
"0"
cellpadding=
"0"
bordercolor=
"#FFFFFF"
>
060.
<tr>
061.
<td height=
"34"
align=
"center"
bgcolor=
"#333333"
style=
""
><span
class
=
"style2"
><font color=
"#FFFFFF"
>วัน/เวลา</font></span></td>
062.
</tr>
063.
<?
064.
$sql5
=
"select * from tb_day"
;
065.
$query5
=mysql_query(
$sql5
);
066.
while
(
$objResult
= mysql_fetch_array(
$query5
)){
067.
?>
068.
<tr>
069.
<td height=
"39"
align=
"center"
bgcolor=
"#999999"
><span
class
=
"style3"
><font color=
"#FFFFFF"
><?php
echo
$objResult
[
"Name_day"
];?></font></span></td>
070.
</tr>
071.
<?
072.
}
073.
?>
074.
</table>
075.
</td>
076.
<td align=
"left"
valign=
"top"
bgcolor=
"#FFFFFF"
>
077.
<?php
078.
079.
$sql
=
"select * from register"
;
080.
$query
=mysql_query(
$sql
);
081.
082.
$timeArr
=
array
(
083.
0 =>
array
(
"start"
=>
"09.00"
,
"stop"
=>
"10.00"
),
084.
1 =>
array
(
"start"
=>
"10.00"
,
"stop"
=>
"11.00"
),
085.
2 =>
array
(
"start"
=>
"11.00"
,
"stop"
=>
"12.00"
),
086.
3 =>
array
(
"start"
=>
"12.00"
,
"stop"
=>
"13.00"
),
087.
4 =>
array
(
"start"
=>
"13.00"
,
"stop"
=>
"14.00"
),
088.
5 =>
array
(
"start"
=>
"14.00"
,
"stop"
=>
"15.00"
),
089.
6 =>
array
(
"start"
=>
"15.00"
,
"stop"
=>
"16.00"
),
090.
7 =>
array
(
"start"
=>
"16.00"
,
"stop"
=>
"17.00"
),
091.
8 =>
array
(
"start"
=>
"17.00"
,
"stop"
=>
"18.00"
),
092.
9 =>
array
(
"start"
=>
"18.00"
,
"stop"
=>
"19.00"
),
093.
10 =>
array
(
"start"
=>
"19.00"
,
"stop"
=>
"20.00"
),
094.
11 =>
array
(
"start"
=>
"20.00"
,
"stop"
=>
"21.00"
),
095.
);
096.
?>
097.
098.
099.
<?php
100.
101.
function
getCol(
$haystack
,
$keyNeedle
)
102.
{
103.
$i
= 0;
104.
foreach
(
$haystack
as
$arr
)
105.
{
106.
if
(
$arr
[
'start'
] ==
$keyNeedle
)
107.
{
108.
return
$i
;
109.
}
110.
$i
++;
111.
}
112.
}
113.
114.
115.
function
getTimeRange(
$timeT
,
$timeCol
){
116.
$data
=
array
();
117.
foreach
(
$timeT
as
$timeA
){
118.
$time
=
$timeA
[
'time'
];
119.
if
(!
$time
)
continue
;
120.
$tm
=
explode
(
"-"
,
$time
);
121.
122.
$start
= getCol(
$timeCol
,
$tm
[0]);
123.
$end
= getCol(
$timeCol
,
$tm
[1] );
124.
$colspan
=
$end
-
$start
;
125.
$data
[
$tm
[0]] =
array
(
'colspan'
=>
$colspan
,
'title'
=>
$timeA
[
'title'
]);
126.
}
127.
return
$data
;
128.
}
129.
?>
130.
<?php
131.
132.
$timeTeach
=
array
(
133.
0 =>
array
(),
134.
1 =>
array
(),
135.
2 =>
array
(),
136.
3 =>
array
(),
137.
4 =>
array
(),
138.
5 =>
array
(),
139.
6 =>
array
()
140.
);
141.
if
(
$_POST
[
"txtKeyword"
] ==
""
){
142.
$date
=
date
(
"Y-m-d"
);
143.
for
(
$i
=0;
$i
<7;
$i
++){
144.
145.
$strSQL
=
"SELECT * FROM tb_register WHERE status = 0 "
;
146.
$query
= mysql_query(
$strSQL
)
or
die
(
"Error Query ["
.
$strSQL
.
"]"
);
147.
while
(
$result
=mysql_fetch_array(
$query
)){
148.
149.
}
150.
}
151.
}
else
{
152.
for
(
$i
=0;
$i
<7;
$i
++){
153.
$strSQL
=
"SELECT * FROM tb_detailregis WHERE 1 "
;
154.
if
(
$_POST
[
"txtKeyword"
] !=
''
){
155.
$strSQL
.=
" AND (ID_student LIKE '"
.
$_POST
[
"txtKeyword"
].
"' ) "
;
156.
}
157.
$query
= mysql_query(
$strSQL
)
or
die
(
"Error Query ["
.
$strSQL
.
"]"
);
158.
while
(
$result
=mysql_fetch_array(
$query
)){
159.
$fetc_pro
= mysql_fetch_array(mysql_query(
"SELECT * FROM tb_register WHERE ID_regis="
.
$result
[
'ID_register'
].
""
));
160.
$Result_tp
= mysql_fetch_array(mysql_query(
"SELECT * FROM tb_typecourse WHERE ID_typeCourse='$fetc_pro[ID_typeCourse]'"
));
161.
$tid
=
$fetc_pro
[
"ID_day"
];
162.
$timeTeach
[
$tid
][] =
array
(
'time'
=>
$fetc_pro
[
"start_time"
].
'-'
.
$fetc_pro
[
"end_time"
],
'title'
=>
'<a href="showregisStd.php?showregisStd_id='
.
$fetc_pro
["ID_regis
"].'"
>'.
$fetc_pro
[
"ID_regis"
].
'</a>'
.
" "
.
$Result_tp
[
"type_name"
]);
163.
}
164.
}
165.
}
166.
167.
?>
168.
169.
<?php
170.
$list
=
""
;
171.
echo
'<table border="1" bordercolor="#FFFFFF" width="100%" align="center" cellspacing="0">'
;
172.
echo
'<tr>'
;
173.
echo
'<td width="8.3%" height="34" colspan="1" align="center" bgcolor="#333333"><font color="#FFFFFF"><span class="style2">9:00-10:00</span></td>'
;
174.
echo
'<td width="8.3%" colspan="1" align="center" bgcolor="#333333"><font color="#FFFFFF"><span class="style2">10:00-11:00</span></td>'
;
175.
echo
'<td width="8.3%" colspan="1" align="center" bgcolor="#333333"><font color="#FFFFFF"><span class="style2">11:00-12:00</span></td>'
;
176.
echo
'<td width="8.3%" colspan="1" align="center" bgcolor="#333333"><font color="#FFFFFF"><span class="style2">12:00-13:00</span></td>'
;
177.
echo
'<td width="8.3%" colspan="1" align="center" bgcolor="#333333"><font color="#FFFFFF"><span class="style2">13:00-14:00</span></td>'
;
178.
echo
'<td width="8.3%" colspan="1" align="center" bgcolor="#333333"><font color="#FFFFFF"><span class="style2">14:00-15:00</span></td>'
;
179.
echo
'<td width="8.3%" colspan="1" align="center" bgcolor="#333333"><font color="#FFFFFF"><span class="style2">15:00-16:00</span></td>'
;
180.
echo
'<td width="8.3%" colspan="1" align="center" bgcolor="#333333"><font color="#FFFFFF"><span class="style2">16:00-17:00</span></td>'
;
181.
echo
'<td width="8.3%" colspan="1" align="center" bgcolor="#333333"><font color="#FFFFFF"><span class="style2">17:00-18:00</span></td>'
;
182.
echo
'<td width="8.3%" colspan="1" align="center" bgcolor="#333333"><font color="#FFFFFF"><span class="style2">18:00-19:00</span></td>'
;
183.
echo
'<td width="8.3%" colspan="1" align="center" bgcolor="#333333"><font color="#FFFFFF"><span class="style2">19:00-20:00</span></td>'
;
184.
echo
'<td width="8.3%" colspan="1" align="center" bgcolor="#333333"><font color="#FFFFFF"><span class="style2">20:00-21:00</span></td>'
;
185.
186.
echo
'</tr>'
;
187.
foreach
(
$timeTeach
as
$i
=>
$arr
){
188.
$timeT
=
$timeTeach
[
$i
];
189.
$arrRange
= getTimeRange(
$timeT
,
$timeArr
);
190.
191.
$list
=
'<tr bgcolor="#E8E8E8">'
;
192.
$chkCol
= 0;
193.
$col
= 0;
194.
foreach
(
$timeArr
as
$timeA
){
195.
$highlight
=
""
;
196.
$colspan
=
""
;
197.
if
(
$chkCol
< (
$col
-1) &&
$col
!= 0){
198.
$chkCol
++;
199.
continue
;
200.
}
201.
$title
=
" "
;
202.
$col
= 0;
203.
$chkCol
= 0;
204.
if
(!
empty
(
$arrRange
[trim(
$timeA
[
'start'
])])){
205.
$col
=
$arrRange
[trim(
$timeA
[
'start'
])][
'colspan'
];
206.
$title
=
$arrRange
[trim(
$timeA
[
'start'
])][
'title'
];
207.
$highlight
=
"highlight"
;
208.
$colspan
=
'colspan="'
.
$col
.
'"'
;
209.
}
210.
$list
.=
'<td '
.
$colspan
.
' class="'
.
$highlight
.
' title" height="39" align="center">'
.
$title
.
'</td>'
;
211.
}
212.
$list
.=
'</tr>'
;
213.
echo
$list
;
214.
}
215.
echo
'</table>'
;
216.
?>
217.
</td>
218.
</tr>
219.
</table>
220.
</table>
221.
</div>
222.
</form>
223.
</div>