Heim  >  Fragen und Antworten  >  Hauptteil

Fehlerdiskussion beim Lunisolar-Kalenderkonvertierungs-Plug-in

Ich habe dieses Plug-in getestet und die folgenden Probleme festgestellt:

①Wenn Jahr und Monat springen, hat der Code <a href='sy1.php?y={$nexty}'>>>< /a>, aber keine sy1.php-Datei vorhanden ist, kann sie in die aktuelle Datei Calendar.php geändert werden.

②Nach dem Sprung ist es zum Beispiel Mai 2018. Wenn ich auf Juni 2018 wechsle und einen der Tage auswähle, wird die Jahres- und Monatstabelle auf den Anfangswert Mai 2018 zurückgesetzt. Bitte geben Sie mir die Antwort. Vielen Dank

邓2327 Tage vor1187

Antworte allen(1)Ich werde antworten

  • 邓

    2018-05-10 11:52:34

    //修复问题②

    改动后代码如下:

    <!DOCTYPE html>

    <html>

    <style>

        table{background:#99ffcc;}

        th{font-family:隶书;color:#0099ff;}

        #tr1{background:#00ccff;}

        .td1{color:#009999;}

        a{color:#ff9900;}

    </style>

    <head>

        <meta charset="UTF-8">

        <script src="jquery-2.2.3.js" type="text/javascript"></script>

    </head>

    <body>

    <?php

    require "./Convert.class.php";

    $convert=isset($_GET["convert"])?$_GET["convert"]:date("Y-m-d");

    //php日历

    //1.date()函数获取当前的年月日

    $year=isset($_GET["y"])?$_GET["y"]:date("Y");

    $mon=isset($_GET["m"])?$_GET["m"]:date("m");

    $day=isset($_GET["d"])?$_GET["d"]:date("d");

    $convert=$year.'-'.$mon.'-'.$day;//组装日期格式

    if($convert!=''){

        $c=new Convert($convert);

        $time=$c->getLyTime();//得到阴历时间

        //    echo $convert.'对应的农历时间:'.$time;

    }

    //2.mktime()函数的使用,获取当前月的天数及当月1号的星期

    $daynum=date("t",mktime(0,0,0,$mon,1,$year));//当前月的天数  31

    $w=date("w",mktime(0,0,0,$mon,1,$year));//当月1号的星期几  4

    //3.输出日历的头部信息

    echo"<div>";

    echo"<table border='0'>";

    echo"<h3><div>{$year}年{$mon}月{$day}日</div></h3>";

    echo "<tr id='tr1'onmouseOver='overTr(this)'onmouseOut='outTr(this)'>";

    echo "<th style='color:#ff0000;'onmouseOver='overTr(this)'onmouseOut='outTr(this)'>日</th>";

    echo "<th>一</th>";

    echo "<th>二</th>";

    echo "<th>三</th>";

    echo "<th>四</th>";

    echo "<th>五</th>";

    echo "<th style='color:#ff0000;'>六</th>";

    echo "</tr>";

    //4.遍历输出日历

    $dayindex=1;

    while($dayindex<=$daynum){

        echo"<tr onmouseOver='overTr(this)'onmouseOut='outTr(this)'>";

        for($i=1;$i<=7;$i++){//循环输出7天信息

        if($dayindex<=$daynum&&($w<$i||$dayindex!=1)){

        //'2014-10-1'(传入这样一个字符串)$year-$month-$d

        if($dayindex==$day){

            echo "<th style='background:#ff0000;'><a href='?y={$year}&m={$mon}&d={$dayindex}'>{$dayindex}</a></th>";

        }else{

            echo "<th onmouseOver='overTh(this)' onmouseOut='outTh(this)'><a href='?y={$year}&m={$mon}&d={$dayindex}'>{$dayindex}</a></th>";

        }

        $dayindex++;

            }else{

     echo"<th> </th>";

            }

        }

    }

    //5.处理上下月,上下年的信息

    $prey=$nexty=$year;

    $prem=$nextm=$mon;

    if($prem<=1){

    $prem=12;

    $prey--;

    }else{

    $prem--;

    }

    if($nextm>=12){

    $nextm=1;

    $nexty++;

    }else{

    $nextm++;

    }

    $prey=$year-1;//上一年

    $nexty=$year+1;//下一年

    //超链接

    echo "<tr  onmouseOver='overTr(this)'onmouseOut='outTr(this)'><td colspan='7'align='center'>";

    echo"<a href='calendar.php?y={$prey}&m={$mon}&d={$day}'><<</a> ";

    echo "<font face='隶书'color='#663399'>{$year}年</font> ";

    echo "<a href='calendar.php?y={$nexty}&m={$mon}&d={$day}'>>></a>  ";

    echo" ";

    echo"<a href='calendar.php?y={$year}&m={$prem}&d={$day}'><</a> ";

    echo "<font face='隶书'color='#663399'>{$mon}月</font> ";

    echo "<a href='calendar.php?y={$year}&m={$nextm}&d={$day}'>></a>";

    echo "</td></tr>";

    echo "<tr onmouseOver='overTr(this)'onmouseOut='outTr(this)'><td colspan='7'>";

    echo "<div>$convert 对应的农历时间:$time</div>";

    echo "</td></tr>";

    echo "</table>";

    echo "</div>";

    ?>

    <script>

    var oriCol=null;

    function  overTr(obj){

    oriCol=obj.bgColor;

    obj.bgColor='#0f0';

    }

    function outTr(obj){

    obj.bgColor=oriCol;

    }

    function overTh(obj) {

        oriCol=obj.bgColor;

        obj.bgColor='red';

    }

    function outTh(obj){

        obj.bgColor=oriCol;

    }

    </script>

    </body>

    </html>


    Antwort
    1
  • StornierenAntwort