001.
<?php
002.
include
(
"../conn/connect_db_server.php"
);
003.
if
(
$_POST
[
'uri'
]==
'book_room.php'
){
004.
$_SESSION
[
'major_code'
] =
$_POST
[
'major'
];
005.
$_SESSION
[
'sub_code'
] =
$_POST
[
'subject'
];
006.
$_SESSION
[
'type_room'
] =
$_POST
[
'classroom'
];
007.
}
008.
009.
print_r(
$_SESSION
);
010.
011.
#
$sql
=
"SELECT * FROM db_booking WHERE ('$book_date_b' BETWEEN book_date_b and book_date_e) "
;
012.
013.
#
$qry
= mysql_query(
$sql
)
or
die
(mysql_error());
014.
#
if
(
$row
= mysql_fetch_array(
$qry
))
015.
#{
016.
#
echo
"ห้องนี้มีผู้ใช้งาน ช่วงเวลา "
.
$row
[
'book_date_b'
] .
" - "
.
$row
[
'book_date_e'
] .
" กรุณาตรวจสอบอีกครั้ง!"
;
017.
#}
018.
#
else
019.
#{
020.
#ส่วนนี้ยังไม่ได้เขียนเลยยยยยยยย
021.
#}
022.
023.
?>
024.
<div
class
=
"container"
>
025.
<form role=
"form"
action=
"book_comple.php"
method=
"post"
>
026.
<div
class
=
"row"
>
027.
<?
028.
#
$sql
=
"SELECT * FROM db_room inner join db_booking on db_room.room_no = db_booking.room_no WHERE type_room='$id_type_room' "
;
029.
$sql
=
"SELECT * FROM db_room WHERE type_room='"
.
$_SESSION
['type_room
']."'
";
030.
echo
"$sql"
;
031.
$result_sql_select_typ
=mysql_query(
$sql
);
032.
033.
$number
=mysql_num_rows(
$result_sql_select_typ
);
034.
035.
$number
= 1;
036.
while
(
$result
= mysql_fetch_array(
$result_sql_select_typ
)){
037.
$id_room
=
$result
[
'id_room'
];
038.
$nick_build
=
$result
[
'nick_build'
];
039.
$room_no
=
$result
[
'room_no'
];
040.
$type_room
=
$result
[
'type_room'
];
041.
$amount
=
$result
[
'amount'
];
042.
$comment
=
$result
[
'comment'
];
043.
#
$book_date_b
=
$result
[
'book_date_b'
];
044.
#
$book_time_b
=
$result
[
'book_time_b'
];
045.
#
$book_date_e
=
$result
[
'book_date_e'
];
046.
#
$Name_surename
=
$result
[
'Name_surename'
];
047.
048.
?>
049.
050.
<div
class
=
"col-md-4"
>
051.
<img src=
"img-build/<? echo $result['room_no'];?>.jpg"
class
=
"img-rounded"
/>
052.
053.
</div>
054.
055.
<div
class
=
"col-md-8"
>
056.
<h4>ห้อง: <?
echo
$result
[
'room_no'
]; ?> </h4>
057.
058.
<p>ประเภทห้อง :<?
if
(
$result
[
'type_room'
]==1)
echo
"ห้องเรียน"
;
059.
if
(
$result
[
'type_room'
]==2)
echo
"ห้อง LAB"
;?> <?
echo
$result
[
'comment'
];?> <br>
060.
จำนวน :<?
echo
$result
[
'amount'
];?> คน<br>
061.
<?php
062.
###
063.
$sqlBooking
=
"SELECT * FROM db_booking WHERE room_no='"
.
$result
['room_no
'] ."'
";
064.
$resultBooking
= mysql_query(
$sqlBooking
);
065.
while
(
$recordBooking
= mysql_fetch_array(
$resultBooking
)){
066.
$book_date_b
=
$recordBooking
[
'book_date_b'
];
067.
$book_time_b
=
$recordBooking
[
'book_time_b'
];
068.
$book_time_e
=
$recordBooking
[
'book_time_e'
];
069.
echo
"วัน : "
;
070.
if
(
$recordBooking
[
'book_date_b'
]== mon)
echo
"วันจันทร์"
;
071.
if
(
$recordBooking
[
'book_date_b'
]== tue)
echo
"วันอังคาร"
;
072.
if
(
$recordBooking
[
'book_date_b'
]== wed)
echo
"วันพุธ"
;
073.
if
(
$recordBooking
[
'book_date_b'
]== thu)
echo
"วันพฤหัสบดี"
;
074.
if
(
$recordBooking
[
'book_date_b'
]== fri)
echo
"วันศุกร์์"
;
075.
if
(
$recordBooking
[
'book_date_b'
]== sat)
echo
"วันเสาร์"
;
076.
if
(
$recordBooking
[
'book_date_b'
]== sun)
echo
"วันอาทิตย์์์"
;
077.
echo
" "
;
078.
echo
$recordBooking
[
'book_time_b'
];
079.
echo
" - "
;
080.
echo
$recordBooking
[
'book_time_e'
];
081.
echo
"<br />"
;
082.
083.
}
084.
###
085.
?>
086.
087.
088.
089.
<br>
090.
091.
092.
<?php
093.
###
094.
#
$sqlBook
=
"SELECT * FROM db_booking WHERE ('$book_time_b' BETWEEN book_time_b and book_time_e) AND room_no = '$result[room_no]'"
;
095.
#
$resultBook
= mysql_query(
$sqlBook
);
096.
#
while
(
$recordBook
= mysql_fetch_row(
$resultBook
)){
097.
#
echo
$recordBook
[0];
098.
#
echo
" - "
;
099.
#
echo
$recordBook
[1];
100.
#
echo
"<br />"
;
101.
#}
102.
###
103.
?>
104.
105.
106.
</p>
107.
<div
class
=
"form-group"
>
108.
<label></label>
109.
<div
class
=
"radio"
>
110.
<label>
111.
<input type=
"radio"
name=
"room_no"
id=
"room_no"
value=
"<? echo $result['room_no']; ?>"
checked>
112.
113.
เลือก
114.
</label></div>
115.
</div>
116.
117.
<br />
118.
<hr>
119.
</div>
120.
121.
<?php
122.
123.
$number
++;
124.
125.
}
126.
127.
mysql_close();
128.
?>
129.
130.
</div><br>
131.
<br>
132.
<div
class
=
"form-group"
>
133.
<label>วันที่เรียน</label>
134.
<select
class
=
"form-control"
id=
"book_date_b"
name=
"book_date_b"
>
135.
<option value=
""
>--กรุณาเลือกเลือกวันที่เรียน--</option>
136.
<option value=
"mon"
>วันจันทร์</option>
137.
<option value=
"tue"
>วันอังคาร</option>
138.
<option value=
"wed"
>วันพุธ</option>
139.
<option value=
"thu"
>วันพฤหัสบดี</option>
140.
<option value=
"fri"
>วันศุกร์</option>
141.
<option value=
"sat"
>วันเสาร์</option>
142.
<option value=
"sun"
>วันอาทิตย์</option>
143.
</select></div>
144.
<div
class
=
"form-group"
>
145.
<label
for
=
"validate-text"
>เริ่มเวลาเรียน</label>
146.
147.
148.
<script type=
"text/javascript"
>
149.
150.
$(
function
(){
151.
$(
"#book_time_b"
).timepicker({
152.
timeFormat:
"HH:mm"
153.
});
154.
});
155.
156.
</script>
157.
158.
<input type=
"text"
name=
"book_time_b"
id=
"book_time_b"
value=
""
class
=
"form-control"
/ placeholder=
"ระบุ วลาที่เริ่มต้น"
required>
159.
160.
161.
162.
163.
164.
</div>
165.
<div
class
=
"form-group"
>
166.
<label
for
=
"validate-text"
>สิ้นสุดเวลาเรียน</label>
167.
168.
169.
<script type=
"text/javascript"
>
170.
171.
$(
function
(){
172.
$(
"#book_time_e"
).timepicker({
173.
timeFormat:
"HH:mm"
174.
});
175.
});
176.
177.
</script>
178.
179.
<input type=
"text"
name=
"book_time_e"
id=
"book_time_e"
value=
""
class
=
"form-control"
/ placeholder=
"ระบุ วลาที่เริ่มต้น"
required>
180.
181.
182.
183.
184.
</div>
185.
186.
<button type=
"reset"
class
=
"btn btn-danger"
>Reset Button</button>
187.
<button type=
"submit"
class
=
"btn btn-success"
>ขั้นตอนต่อไป >></button>
188.
<!--<input type=
"hidden"
name=
"type_room"
value=
"<?=$_SESSION['type_room'] ?>"
/>
189.
<input type=
"hidden"
name=
"sub_code"
value=
"<?=$_SESSION['sub_code']?>"
/>-->
190.
</form>