|
 |
|
ช่วยแก้โค้ดให้หน่อยครับ จากวัน เป็นชื่อห้องที่ดึงจากฐานข้อมูล |
|
 |
|
|
 |
 |
|
อยากเปลี่ยนจากวัน เป็นชื่อห้อง ที่ดึงจากฐานข้อมูลครับ ต้องเขียนโค้ด select อย่างไรครับ

Code (PHP)
<?php
$time = mktime(0,0,0,1,1,2009);
$p = 1800;
$eight_am = $time + 60*60*8;
$nine_pm = $time + 60*60*20;
$weeks = array('จันทร์','อังคาร','พุธ','พฤหัส','ศุกร์','เสาร์','อาทิตย์');
$colors = array('yellow','pink','green','orange','lightblue','purple','red');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="th" xml:lang="th">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>period of the day</title>
<style type="text/css">
.tb1 {border-collapse:collapse;}
.tb1 .tr1 {font-size:11px;}
.tb1 td{border:solid silver 1px;padding-right:3px;}
</style>
</head>
<body>
<?php
if (!empty($_POST['day_and_period'])){
echo 'date and peroid:<hr>';
foreach($_POST['day_and_period'] as $dp){
list($day, $period) = explode('##', $dp);
list($start_p, $end_p) = explode('-', $period);
echo 'day: ',$day,'(',$weeks[$day],')';
echo '<br>period: ',$period;
echo '<br>start: ',$start_p;
echo '<br>end: ',$end_p;
echo '<hr>';
}
}
?>
<form method="post" action="" id="box">
<table border="1" class="tb1">
<tr class="tr1">
<td>วัน/เวลา</td>
<?php for($i=$eight_am; $i<$nine_pm; $i+=$p):?>
<?php $t = date('H:i',$i); ?>
<?php $t2 = date('H:i',$i+$p); ?>
<td>
<?php echo $t,'<br/>',$t2;?>
</td>
<?php endfor;?>
</tr>
<?php foreach(range(0,6) as $d):?>
<tr>
<td bgcolor="<?php echo $colors[$d];?>"><?php echo $weeks[$d]; ?></td>
<?php for($i=$eight_am; $i<$nine_pm; $i+=$p):?>
<?php $t = date('H:i',$i); ?>
<?php $t2 = date('H:i',$i+$p); ?>
<td>
<input type="checkbox" name="day_and_period[]" value="<?php echo $d,'##',$t,'-',$t2;?>" />
</td>
<?php endfor;?>
</tr>
<?php endforeach;?>
</table>
<input type="submit" value="submit" />
</form>
</body>
</html>
Tag : PHP, MySQL

|
|
 |
 |
 |
 |
Date :
2011-05-21 14:52:40 |
By :
baipan14 |
View :
609 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ที่ให้มาไม่มีคำสั่ง sql เลยครับ แต่ถ้าจะดีงข้อมูลก็ใช้
$sql = "select * from tb_name ";
$rs = mysql_query($sql);
while($array = mysql_fetch_array($rs)){
echo $field['ชื่อห้อง'];
}
|
 |
 |
 |
 |
Date :
2011-05-21 15:36:54 |
By :
Dragons_first |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แล้วเราจะเอาโค้ดนี้ไปใส่ตรงไหนอ่ะคับ
|
 |
 |
 |
 |
Date :
2011-05-21 17:17:01 |
By :
baipan14 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|