我有一个事件日历,根据用户选择的 4 个下拉菜单选项,我从数据库中打印出某些信息,这些是Week
Month
Year
和Order
,当提供所有选项时,应用程序显示良好。现在我遇到的问题是,我希望将事件日历的默认视图设置为当前时间week
Month
,Year
这样用户就不必选择下拉菜单来查看它。
当我实现下面的代码部分时,事件日历上什么也没有发生
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 }
}
}
?>