Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/401.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 赢得比赛';不会出现在php日历上_Javascript_Php_Mysql_Ajax_Calendar - Fatal编程技术网

Javascript 赢得比赛';不会出现在php日历上

Javascript 赢得比赛';不会出现在php日历上,javascript,php,mysql,ajax,calendar,Javascript,Php,Mysql,Ajax,Calendar,我制作了一个php事件日历,可以在月份之间切换,但是当我将事件添加到数据库中时,它不会出现在我的日历上。非常感谢您的帮助 代码: show calendar.php <html> <head> <link href="calstyle.css" rel="stylesheet" type="text/css" media="all" /> <script language="JavaScript" type="text/javascript"> f

我制作了一个php事件日历,可以在月份之间切换,但是当我将事件添加到数据库中时,它不会出现在我的日历上。非常感谢您的帮助

代码: show calendar.php

<html>
<head>
<link href="calstyle.css" rel="stylesheet" type="text/css" media="all" />
<script language="JavaScript" type="text/javascript">
function initialCalendar(){
    var hr = new XMLHttpRequest();
    var url = "calendar_start.php";
    var currentTime = new Date ();
    var month = currentTime.getMonth() + 1;
    var year = currentTime.getFullYear();
    showmonth = month;
    showyear = year;
    var vars= "showmonth="+showmonth+"&showyear="+showyear;
    hr.open("POST", url, true);
    hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    hr.onreadystatechange = function() {
        if (hr.readyState == 4 && hr.status == 200) {
            var return_data = hr.responseText;
                document.getElementById("showCalendar").innerHTML = return_data;
        }
    }
    hr.send(vars);
    document.getElementById("showCalendar"). innerHTML = "processing...";
}
</script>
<script language="JavaScript" type="text/javascript">
function next_month() {
    var nextmonth = showmonth + 1;
    if(nextmonth > 12) {
        nextmonth = 1;
        showyear = showyear+1;
    }
    showmonth = nextmonth;
    var hr = new XMLHttpRequest();
    var url = "calendar_start.php";
    var vars= "showmonth="+showmonth+"&showyear="+showyear;
    hr.open("POST", url, true);
    hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    hr.onreadystatechange = function() {
        if (hr.readyState == 4 && hr.status == 200) {
            var return_data = hr.responseText;
                document.getElementById("showCalendar").innerHTML = return_data;
        }
    }
    hr.send(vars);
    document.getElementById("showCalendar"). innerHTML = "processing...";
}
</script>
<script language="JavaScript" type="text/javascript">
function last_month() {
    var lastmonth = showmonth - 1;
    if(lastmonth < 1 ) {
        lastmonth = 12;
        showyear = showyear-1;
    }
    showmonth = lastmonth;
    var hr = new XMLHttpRequest();
    var url = "calendar_start.php";
    var vars= "showmonth="+showmonth+"&showyear="+showyear;
    hr.open("POST", url, true);
    hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    hr.onreadystatechange = function() {
        if (hr.readyState == 4 && hr.status == 200) {
            var return_data = hr.responseText;
                document.getElementById("showCalendar").innerHTML = return_data;
        }
    }
    hr.send(vars);
    document.getElementById("showCalendar"). innerHTML = "processing...";
}
</script>
<script type="text/javascript">
function overlay() {
    el = document.getElementById("overlay");
    el.style.display = (el.style.display == "block") ? "none" : "block";
    el. = document.getElementById("events");
    el.style.display = (el.style.display == "block") ? "none" : "block";
    el. = document.getElementById("eventsBody");
    el.style.display = (el.style.display == "block") ? "none" : "block";
}
</script>
<script language="javascript" type="text/javascript">
function show_details(theId) {
    var deets = )theId.id);
    el = document.getElementById("overlay");
    el.style.display = (el.style.display == "block") ? "none" : "block";
    el. = document.getElementById("events");
    el.style.display = (el.style.display == "block") ? "none" : "block";
    var hr = new XMLHttpRequest();
    var url = "events.php";
    var vars = "deets="+deets;
    hr.open("POST", url, true);
    hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    hr.onreadystatechange= function() {
        if (hr.readyState == 4 && hr.status == 200) {
            var return_data = hr.responseText;
                document.getElementById("events").innerHTML = return_data;
        }
    }
    hr.send(vars);
    document.get ElementById("events").innerHTML = "processing...";
}
</script>
</head>
<body onload="initialCalendar();">
<div id="showCalendar"> </div>
<div id="overlay">
    <div id="events"></div>
</div>
</body>
</html>

函数initialCalendar(){
var hr=新的XMLHttpRequest();
var url=“calendar\u start.php”;
var currentTime=新日期();
var month=currentTime.getMonth()+1;
var year=currentTime.getFullYear();
showmonth=月份;
showyear=year;
var vars=“showmonth=“+showmonth+”&showyear=“+showyear;
hr.open(“POST”,url,true);
hr.setRequestHeader(“内容类型”、“应用程序/x-www-form-urlencoded”);
hr.onreadystatechange=函数(){
如果(hr.readyState==4&&hr.status==200){
var return_data=hr.responseText;
document.getElementById(“showCalendar”).innerHTML=返回\u数据;
}
}
人力资源发送(vars);
document.getElementById(“showCalendar”).innerHTML=“处理…”;
}
下个月的职能(){
var nextmonth=showmonth+1;
如果(下个月>12){
下个月=1;
showyear=showyear+1;
}
showmonth=下一个月;
var hr=新的XMLHttpRequest();
var url=“calendar\u start.php”;
var vars=“showmonth=“+showmonth+”&showyear=“+showyear;
hr.open(“POST”,url,true);
hr.setRequestHeader(“内容类型”、“应用程序/x-www-form-urlencoded”);
hr.onreadystatechange=函数(){
如果(hr.readyState==4&&hr.status==200){
var return_data=hr.responseText;
document.getElementById(“showCalendar”).innerHTML=返回\u数据;
}
}
人力资源发送(vars);
document.getElementById(“showCalendar”).innerHTML=“处理…”;
}
上个月的功能(){
var lastmonth=showmonth-1;
如果(上个月<1){
上月=12;
showyear=showyear-1;
}
showmonth=上个月;
var hr=新的XMLHttpRequest();
var url=“calendar\u start.php”;
var vars=“showmonth=“+showmonth+”&showyear=“+showyear;
hr.open(“POST”,url,true);
hr.setRequestHeader(“内容类型”、“应用程序/x-www-form-urlencoded”);
hr.onreadystatechange=函数(){
如果(hr.readyState==4&&hr.status==200){
var return_data=hr.responseText;
document.getElementById(“showCalendar”).innerHTML=返回\u数据;
}
}
人力资源发送(vars);
document.getElementById(“showCalendar”).innerHTML=“处理…”;
}
函数覆盖(){
el=document.getElementById(“覆盖”);
el.style.display=(el.style.display=“块”)?“无”:“块”;
el.=document.getElementById(“事件”);
el.style.display=(el.style.display=“块”)?“无”:“块”;
el.=document.getElementById(“eventsBody”);
el.style.display=(el.style.display=“块”)?“无”:“块”;
}
功能显示详细信息(theId){
var deets=)theId.id);
el=document.getElementById(“覆盖”);
el.style.display=(el.style.display=“块”)?“无”:“块”;
el.=document.getElementById(“事件”);
el.style.display=(el.style.display=“块”)?“无”:“块”;
var hr=新的XMLHttpRequest();
var url=“events.php”;
var vars=“deets=”+deets;
hr.open(“POST”,url,true);
hr.setRequestHeader(“内容类型”、“应用程序/x-www-form-urlencoded”);
hr.onreadystatechange=函数(){
如果(hr.readyState==4&&hr.status==200){
var return_data=hr.responseText;
document.getElementById(“事件”).innerHTML=返回\u数据;
}
}
人力资源发送(vars);
document.get ElementById(“事件”).innerHTML=“处理…”;
}
calendar_start.php

<?php
$showmonth = $_POST['showmonth'];
$showyear = $_POST['showyear'];
$showmonth= preg_replace('#[^0-9]#i', '', $showmonth);
$showyear= preg_replace('#[^0-9]#i', '', $showyear);

$day_count = cal_days_in_month(CAL_GREGORIAN, $showmonth, $showyear);
$pre_days = date('w', mktime(0,0,0, $showmonth, 1, $showyear));
$post_days = (6-(date('w', mktime(0,0,0, $showmonth, $day_count, $showyear))));

echo '<div id="calendar_wrap">';
echo '<div class="title_bar">';
echo '<div class="previous_month"><input name="button" type="submit" value="Previous Month" onClick="javascript:last_month();"></div>';
echo '<div class="show_month">'  . date('F', mktime(0, 0, 0, $showmonth)) . ' ' . $showyear . '</div>';
echo '<div class="next_month"><input name="button" type="submit" value="Next Month" onClick="javascript:next_month();"></div>';
echo '</div>';

echo '<div class="week_days">';
echo '<div class="days_of_the_week">Sun</div>';
echo '<div class="days_of_the_week">Mon</div>';
echo '<div class="days_of_the_week">Tues</div>';
echo '<div class="days_of_the_week">Wed</div>';
echo '<div class="days_of_the_week">Thur</div>';
echo '<div class="days_of_the_week">Fri</div>';
echo '<div class="days_of_the_week">Sat</div>';
echo '<div class="clear"></div>';
echo '</div>';

if ($pre_days != 0) { 
    for($i=1; $i<=$pre_days; $i++) {
        echo '<div class="non_cal_day"></div>';
    }
}
include ("connect.php");
for ($i=1; $i<= $day_count; $i++) {
    $date = $i.'/'.$showmonth.'/'.$showyear;
$query = "Select id FROM events WHERE evDate = '$date'";
$num_rows = 0;
if($result = mysql_query($query)) {
    $num_rows = mysql_num_rows($result);
}
    if($num_rows > 0) {
        $event = "<input name='$date' type='submit' value='Details' id='$date'
onClick='javascript:show_details(this);'>";
    }
    echo '<div class="cal_day">';
    echo '<div class="day_heading">' . $i . '</div>';
    if($num_rows != 0) { echo "<div class='openings'><br/>" . $event . "</div>";}
    echo '</div>';
}

if ($post_days !=0) {
    for($i=1; $i<=$post_days; $i++) {
        echo '<div class="non_cal_day"></div>';
    }
}
echo '</div>';
?>

下面的代码显示了一些语法错误

while($row= mysql_fetch_array($query)) {
        $desc = $row['description'];
        $events .='<div id="eventsBody"> . $desc .'<br /><hr><br /></div>';
    }
while($row=mysql\u fetch\u array($query)){
$desc=$row['description'];
$events.='.$desc.


; }
应该是

while($row= mysql_fetch_array($query)) {
        $desc = $row['description'];
        $events .='<div id="eventsBody">'.$desc .'<br /><hr><br /></div>';
    }
while($row=mysql\u fetch\u array($query)){
$desc=$row['description'];
$events.=''.$desc.


; }
这是问题的一部分,您能否检查您的查询是否返回任何数据?
while($row= mysql_fetch_array($query)) {
        $desc = $row['description'];
        $events .='<div id="eventsBody"> . $desc .'<br /><hr><br /></div>';
    }
while($row= mysql_fetch_array($query)) {
        $desc = $row['description'];
        $events .='<div id="eventsBody">'.$desc .'<br /><hr><br /></div>';
    }