|
 |
|
รบกวนช่วยแก้ตารางนัดหมายกิจกรรมหน่อยครับ ไม่รู้จะใช้เงื่อนไขไหนแสดงผล |
|
 |
|
|
 |
 |
|
คือจะทำปฏิทินกิจกรรม โดยเชื่อมกับSQL เท่าที่ผมหาโค๊ดมาดัดแปลงแล้วมันไม่แสดงข้อมูลจากฐานข้อมูลตามที่ต้องการ ตอนแรกลองทำเชื่อมฐานข้อมูลได้ดึงเนื้อหามาแสดงได้แต่ไม่ขึ้นตามเงื่อนไขที่กำหนดคือมันขึ้นแสดงเนื้อหาเดียวกันทุกวันเลย พอพยามแก้เงื้อนไขการแสดงไปเลื่อยๆ ก็ไม่ได้ซะที ช่วยชี้แนะด้วยครับ
ผลที่พยามลองมั่วดู

อันนี้โค๊ด
Code (PHP)
<?
session_start();
if($_SESSION['UserID'] == "")
{
echo "Please Login!";
exit();
}
mysql_connect("localhost","root","1234");
mysql_query("SET NAMES TIS620");
mysql_select_db("banmordek");
$strSQL = "SELECT * FROM user WHERE UserID = '".$_SESSION['UserID']."' ";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<style>
.now
{
background:red;
color: greenyellow;
}
.Td_theme
{
height:84px;
width:110px;
}
</style>
<?php
//var_dump($_POST);
//echo "There was $num days in DEC 2012";
echo "<br />";
//echo " " . date("l", mktime(0, 0, 0, 12, 1, 2012));
$month_set=date("m");
$day_set=1;
$year_set=date("Y");
$now=date("d");
if(isset($_POST['console']))
{
if($_POST['console']=="<<"&&$_POST['month']=="1")
{
$month_set=12;
$year_set=--$_POST['year'];
}else if($_POST['console']=="<<")
{
$month_set=--$_POST['month'];
$year_set=$_POST['year'];
}else if($_POST['console']==">>"&&$_POST['month']=="12")
{
$month_set=1;
$year_set=++$_POST['year'];
}else if($_POST['console']==">>")
{
$month_set=++$_POST['month'];
$year_set=$_POST['year'];
}
}else if(isset($_POST['today']))
{
$month_set=date("m");
$day_set=1;
$year_set=date("Y");
}
$day_count = cal_days_in_month(CAL_GREGORIAN, $month_set, $year_set);
$format=date("l", mktime(0, 0, 0, $month_set, $day_set, $year_set));
if($format=='Saturday')
{
$day_start=7;
}else if($format=='Sunday')
{
$day_start=1;
}else if($format=='Monday')
{
$day_start=2;
}else if($format=='Tuesday')
{
$day_start=3;
}else if($format=='Wednesday')
{
$day_start=4;
}else if($format=='Thursday')
{
$day_start=5;
}else
{
$day_start=6;
}
?>
<form method="POST" action="calendar.php">
<div style="margin-left: 350px;"><?php echo date("F-Y", mktime(0, 0, 0, $month_set, $day_set, $year_set)); ?></div>
-----------------------------------------------------------
<input type="hidden" name="month" value="<?php echo $month_set; ?>" />
<input type="hidden" name="year" value="<?php echo $year_set; ?>" />
<input type="submit" name="today" value="TODAY" />
<input type="submit" name="console" value="<<">
<input type="submit" name="console" value=">>">
------------------------------------------------------------
</form>
<table class="table_theme" border="2px" >
<?php
echo "<th> Sunday </th>";
echo "<th> Monday </th>";
echo "<th> Tuesday </th>";
echo "<th> Wednesday </th>";
echo "<th> Thursday </th>";
echo "<th> Friday </th>";
echo "<th> Saturday </th>";
$count=1;
$day=1;
//$day_count=31;
if($day_start>=6&&$day_count>=31)
{
$row=0;
}else if($day_start==1&&$day_count<=28)
{
$row=2;
}else
{
$row=1;
}
for($row; $row<=5; $row++)
{
echo "<tr>";
for($col=0; $col<=6; $col++)
{
echo '<td class="Td_theme" >';
if($day_start<=$count&&$day<=$day_count)
{
if($month_set==date("m")&&$year_set==date("Y")&&$day==$now)
{
echo "<div class='now'><h4><center>ToDay</h4></div>";
}
echo $day++;
mysql_connect("localhost","root","1234");
mysql_query("SET NAMES TIS620");
mysql_select_db("banmordek");
$strSQL = "SELECT * FROM activity";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
?><input name="textfield3" type="text" id="textfield3" value=" <?=$objResult["ACTIVITY_SUBJECT"];?>" readonly="readonly" /><?
}
$count++;
echo "</td>";
}
echo "</tr>";
}
?>
</table>
</body>
</html>
รบกวนชี้แนะด้วยครับ
Tag : PHP, MySQL, CakePHP

|
|
 |
 |
 |
 |
Date :
2014-05-04 17:03:20 |
By :
Rei |
View :
4105 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ทีนี้ผมลองใช้เงื่อนไขพยามกำหนดวันลงไป คราวนี้ไม่ขึ้นแสดงอะไรเลยครับ
อันนี้ที่ผมลองเพิ่มเข้าไปดู
Code (PHP)
$strSQL = "SELECT * FROM activity WHERE ACTIVITY_ID='".$day."'";
|
 |
 |
 |
 |
Date :
2014-05-04 17:12:22 |
By :
Rei |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|