2
我有事件的日曆由此我根據由用戶選擇4下拉菜單選項,從該數據庫打印出某些信息,這些都是Week
Month
Year
和Order
,該應用程序顯示以及所有選項都提供時。現在我遇到的問題是,我希望將事件日曆的默認視圖設置爲當前時間的week
Month
和Year
,以便用戶不必選擇下拉菜單即可查看該事件。如何爲PHP日曆默認視圖值
當我執行下面的代碼的一部分,什麼都不會發生的事件
PHP
function calendar()
{
if(!isset($_POST['submit'])){
$m = date('M');
$day = date('j');
$Y = date('Y');
if ($day >= 29) {
$j = 5;
}elseif($day >= 22 AND $day < 28) {
$j = 4;
}elseif($day >= 15 AND $day < 22) {
$j = 3;
}elseif($day >=8 AND $day < 15) {
$j = 2;
}else{
$j = 1;
}
}
if(isset($_POST['submit'])){
if ($_POST['submit'] == ""){
echo "No Event for Today" ;
}
$j = mysql_real_escape_string($_POST['week']);
$m = mysql_real_escape_string($_POST['month']);
$Y = mysql_real_escape_string($_POST['year']);
$o = mysql_real_escape_string($_POST['order']);
$date =" ".$j.", ".$Y." ";
$query1 = " SELECT *
FROM newcaldemo
WHERE eventweek = '".$j."'
AND month = '".$m."'
AND year = '".$Y."'
ORDER by $o ASC" ;
$run1 = mysql_query($query1);
$norows = mysql_affected_rows();
if ($norows < 1){
echo "No Event(s) for Week $j, $Y" ;
} else {
echo "Event(s) for Week $j, $m $Y <br></div> ";
while($row1 = mysql_fetch_array($run1)) { ?>
<?php echo $row1['month']." " .$row1['day'] ; ?><br>
Name : <?php echo $row1['eventname'] ; ?><br>
Time : <?php echo $row1['eventtime'] ; ?><br>
Venue : <?php echo $row1['eventplace'] ; ?><br>
<?php }
}
}
?>