 |
|
โค๊ดตอนนี้คือ ถ้ามีคนจองเข้ามาและชำระเงินจะขึ้นสีแดงครับ ถ้าไม่มีการจองจะว่าง สิ่งที่ผมต้องการคือ ถ้ามีการจองมาแล้วแต่ยังไม่ชำระเงินให้ขึ้นสีเหลือครับ ไม่รู้จะเพิ่มตรงไหน ใครรู้ช่วยทีครับ ขอบคุณครับ
ตอนนี้ผมใช้เป็นแบบกำหนดค่า status คือ จองชำระเงินให้เท่ากับ 2 ยังไม่ชำระให้เท่ากับ 1 ว่างให้เท่ากับ 0 ครับ
Code (PHP)
<table width="490" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<table width="490" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20%" height="35" align="center">
<font color="#0000FF" size="4">
เช็คห้องว่าง</font>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="calendar">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0" >
<tr bgcolor="#004080" class="title">
<td width="11%" align="center" bgcolor="#9C9A31" class="title" ><a href="<?php echo "$PHP_SELF?Y=$cal_prev_year&m=$cal_prev_month&d=$cal_day" ?><? echo"&home_code=$home_code" ?>">BACK</a></td>
<td width="78%" height="30" align="center" bgcolor="#9C9A31"><font face="Tahoma" color="#FFFFFF" size="3"><?php echo $_month_name[$cal_month]." - ".($cal_year+543);?></font></td>
<td width="11%" align="center" bgcolor="#999933" class="title"><a href="<?php echo "$PHP_SELF?Y=".$cal_next_year."&m=".$cal_next_month."&d=".$cal_day;?><? echo"&home_code=$home_code" ?>">NEXT</a></td>
</tr>
</table>
<!-- ตารางแสดงปฏิทิน -->
<table width="490" border="0" align="center" cellpadding="0" cellspacing="2" bgcolor="#99CC33" class="overview" >
<tr>
<td width="70" height="25" align="center" class="dayname"><strong>จันทร์</strong></td>
<td width="70" align="center" class="dayname"><strong>อังคาร</strong></td>
<td width="70" align="center" class="dayname"><strong>พุธ</strong></td>
<td width="70" align="center" class="dayname"><strong>พฤหัสบดี</strong></td>
<td width="70" align="center" class="dayname"><strong>ศุกร์</strong></td>
<td width="70" align="center" class="dayname"><strong>เสาร์</strong></td>
<td width="70" align="center" class="dayname"><strong>อาทิตย์</strong></td>
</tr>
<?php
require_once('Connections/connresort.php');
mysql_select_db($database_connresort, $connresort);
$query_rsCal = "select start,end ,order_status from mycalendar where home_code='$home_code' ";
$rsCal = mysql_query($query_rsCal, $connresort) or die(mysql_error());
$row_rsCal = mysql_fetch_assoc($rsCal);
//เอาวันเริ่มและสิ้นสุดมาเก็บใน array เพื่อใช้ในการเปรียบเทียบ
$st=array();$ed=array();
$i=0;
do{
$st[$i]=$row_rsCal['start'];
$ed[$i]=$row_rsCal['end'];
$i++;} while ($row_rsCal = mysql_fetch_assoc($rsCal));
for($i=0;$i<count($st);$i++)
{
$ed[$i]=substr($ed[$i],0,4).substr($ed[$i],5,2).substr($ed[$i],8,2);
$st[$i]=substr($st[$i],0,4).substr($st[$i],5,2).substr($st[$i],8,2);
}
if ( ( $cal_year == $cur_year ) && ( $cal_month == $cur_month ) )
{
$today_day = $cur_day;
} else $today_day = 0;
//จำนวนวันในเดือนที่แล้ว จำนวนวันในเดือนนี้ หาค่าวันที่ 1 ของเดือนแบบสัปดาห์
$days_last_month = num_days( $cal_prev_year, $cal_prev_month );
$days_this_month = num_days( $cal_year, $cal_month );
$first_day_pos = date( "w", mktime( 0,0,0,$cal_month,1,$cal_year) );
//เปลี่ยนค่าที่ได้ถ้าเป็นวันอาทิตย์ให้เท่ากับ 7 แทน Mo=1 to Su=7
if ( $first_day_pos == 0 ) $first_day_pos = 7;
$day_num= $days_last_month - ($first_day_pos-2);
$class="last_month";
$p=array();
for ( $y=1; $y<=5; $y++ )
{
echo "<tr>";
for ( $x=1; $x<=7; $x++ )
{
if ( ($y==1) && ($x==$first_day_pos) )
{
$day_num = 1; $class="";
}
if ( ($y >1) && ($day_num>$days_this_month) )
{
$day_num = 1; $class="next_month";
}
if ( ($class=="") && ($day_num == $today_day) )
{
$id="today";
} else $id="";
if ( $class == "" ){
if($cal_month<=9)
$mm="0".$cal_month;
else $mm=$cal_month;
if($day_num<=9)
$dd="0".$day_num;
else $dd=$day_num;
$times=$cal_year."-".$mm."-".$dd;
}
$cur_day=$cal_year.$mm.$dd;
for($i=0;$i<count($st);$i++){
if(($cur_day>=$st[$i])&&($cur_day<=$ed[$i])){
$p[$day_num]=1;
}
}
if($p[$day_num]==1&&$class==""){
?>
<td height="50" align="center" class=<? echo" $class"; ?> id=<? echo" $id"; ?>><font color=#FFFFFF size=3><B><? echo"$day_num"; ?></B></font></td>
<? }else{ echo "<td height=50 class='".$class."' id='".$id."' bgcolor=#FFFFFF><div align='center'>".$day_num."</div></td>";
}
$day_num++;
}
echo "</tr>";
}
?><!--สิ้นสุดปฏิทินเหตุการณ์ -->
</table>
</td>
</tr>
</table>
</td></tr></table></td>
</tr>
</table>
Tag : PHP, MySQL
|
|
 |
 |
 |
 |
Date :
2011-08-04 10:59:16 |
By :
tawat |
View :
959 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |