|
|
|
รบกวนแก้ code ให้หน่อยจ้า อย่างที่เห็นอ่ะค่ะ คือมันล้นออกมาอยู่ รบกวนแก้ให้หน่อยค่ะ ปวดหัวหมดแล้ว |
|
|
|
|
|
|
|
อย่างที่เห็นอ่ะค่ะ คือมันล้นออกมาอยู่
รบกวนแก้ให้หน่อยค่ะ ปวดหัวหมดแล้ว
Code (PHP)
<html>
<head>
<title>Generate Schedule</title>
<link rel="shortcut icon" href ="lang.libarts/website_icon_collection1.ico">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<?php
$day=array("1"=>"Monday","2"=>"Tuesday","3"=>"Wednesday","4"=>"Thursday","5"=>"Friday","6"=>"Saturday","7"=>"Sunday");
$host = "sql106.pr.in.th";
$user = "modty_5217551";
$password = "xk06J53";
$database = "modty_5217551_schedule";
$link = mysql_connect($host, $user, $password);
mysql_select_db($database, $link);
mysql_query("SET NAMES UTF8");
mysql_query("SET character_set_results=utf8");
mysql_query("SET character_set_client=utf8");
mysql_query("SET character_set_connection=utf8");
$select = "select * from officehour where academic='".$_POST[academic]."'";
$result = mysql_query($select, $link);
$row=mysql_fetch_array($result);
$numrows=mysql_num_rows($result);
$numfields=mysql_num_fields($result);
if(!$result){
echo mysql_error();
}elseif($numrows==0){
echo "<b>Can not find your search result!!<br><a href='office_hours2.php'> <<< Back</a></b>"."\n";
}else{
echo "<h3 style='text-align:center'>Faculty of Liberal Arts<br>Prince of Songkla University<br>";
echo "Schedule for Academic year ".$_POST[academic]."</h3><br>";
echo "<table border='1' width='100%'>";
echo "<tr style='font-weight:bold; text-align:center'>";
echo "<td colspan='2'>Date-Time</td>"."\n";
echo "<td colspan='2'>8.00-8.50</td>"."\n";
echo "<td colspan='2'>9.00-9.50</td>"."\n";
echo "<td colspan='2'>10.00-10.50</td>"."\n";
echo "<td colspan='2'>11.00-11.50</td>"."\n";
echo "<td colspan='2'>12.00-12.50</td>"."\n";
echo "<td colspan='2'>13.00-13.50</td>"."\n";
echo "<td colspan='2'>14.00-14.50</td>"."\n";
echo "<td colspan='2'>15.00-15.50</td>"."\n";
echo "<td colspan='2'>16.00-16.50</td>"."\n";
echo "<td colspan='2'>17.00-17.50</td>"."\n";
echo "<td colspan='2'>18.00-18.50</td>"."\n";
echo "<td colspan='2'>19.00-19.50</td>"."\n";
echo "<td colspan='2'>20.00-20.50</td>"."\n";
echo "</tr>"."\n";
for($j=1; $j<=7; $j++){//loop for display date
$counter2=0;
$counter[$j] = "select * from officehour where date='".$j."'";
$counted[$j] = mysql_query($counter[$j], $link);
$numrows2[$j] = mysql_num_rows($counted[$j]);
//if schedule has overlap time to display will do this
if($numrows2[$j]>1){
echo "<tr>";
echo "<td style='font-weight:bold; text-align:center' colspan='2' rowspan='".$numrows2[$j]."'>".$day[$j]."</td>"."\n";
}else{
echo "<tr>";
echo "<td style='font-weight:bold; text-align:center' colspan='2'>".$day[$j]."</td>"."\n";
}
$result = mysql_query($select, $link);
while($row=mysql_fetch_array($result)){
$count = 25; //if there are no matching date of reserv, $count is set to 25
if($row[date]==$j){ //check date in draw schedule
$time = $row[time_in]; //use to check where to start draw schedule
for($k=0; $k<$row[time_in]; $k+=2){
if($time%2==0){
echo "<td align='center' colspan='2'> <br> </td>"."\n";
$time-=2;
}
if($time%2!=0){
echo "<td align='center' width='3.57%'> <br> </td>"."\n";
$time--;
}
}
$period = $row[time_out]-$row[time_in];
if($period!=0){
if($numrows2[$j]>1&&$counter2!=0){
echo "<tr>";
$time = $row[time_in];
for($k=0; $k<$row[time_in]; $k+=2){
if($time%2==0){
echo "<td align='center' colspan='2'> <br> </td>"."\n";
$time-=2;
}
if($time%2!=0){
echo "<td align='center' width='3.57%'> <br> </td>"."\n";
$time--;
}
}
}
//display value of field
$count=$count-($row[time_in]+($period)); //calculate for space after input the time
echo "<td align='center' colspan='".$period ."'>".$row[name]."<br>R. ".$row[room]."</td>"."\n";
$counter2++;
//blank space for schedule after input the time if have rowspan
if($numrows2[$j]>1&&$counter2!=0){
if($count%2==0){
echo "<td width='3.57%'> <br> </td>"."\n";
$count--;
}
if($count%2!=0){
$count=($count/2); //divine to colspan
for($i=0; $i<$count; $i++){
echo "<td colspan='2'> <br> </td>"."\n";
}
}
}
}
}
}
//blank space for schedule after input the time
if($count%2==0){
echo "<td width='3.57%'> <br> </td>"."\n";
$count--;
}
if($count%2!=0){
$count=($count/2); //divine to colspan
for($i=0; $i<$count; $i++){
echo "<td colspan='2'> <br> </td>"."\n";
}
}
echo "</tr>"."\n";
}
}
echo "</tr>";
echo "</table>";
?>
</body>
</html>
Tag : - - - -
|
|
|
|
|
|
Date :
2010-04-05 16:30:43 |
By :
Andontae |
View :
827 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ผมว่าคนทำน่าจะสามารถแก้ไขปัญหาได้ดีที่สุดน่ะครับ
|
|
|
|
|
Date :
2010-04-05 20:54:58 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|