Lunisolar calendar conversion plug-in bug discussion
邓
2018-05-10 10:33:03
0
1
1255

I tested this plug-in and found the following problems:

①When the year and month jump, the code has <a href='sy1.php?y={$nexty}'> >></a> , but the sy1.php file does not exist, it can be changed to the current file calendar.php.

②After the jump, for example, it is May 2018. If I switch to June 2018 and select one of the days, the year and month table will return to the initial value of May 2018. Please give me the answer. Thank you

邓

reply all(1)
邓

//Fix the problem ②

The modified code is as follows:

<!DOCTYPE html>

<html>

<style&gt ;

table{background:#99ffcc;}

th{font-family:official script;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 calendar

//1.date() function gets the current year, month and day

$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;//Assembly date Format

if($convert!=''){

$c=new Convert($convert);

$time=$c->getLyTime() ;//Get the lunar time

// echo $convert.'Corresponding lunar time:'.$time;

}

//2.mktime() function Use to get the number of days in the current month and the day of the week on the 1st of the month

$daynum=date("t",mktime(0,0,0,$mon,1,$year));//current The number of days in the month 31

$w=date("w",mktime(0,0,0,$mon,1,$year));//The day of the week on the 1st of the month 4

//3. Output the header information of the calendar

echo"<div>";

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

echo"<h3><div>{$year}year{$mon}month{$day}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>four</th>";

echo "<th>five</th>";

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

echo "</tr>";

//4. Traverse the output calendar

$dayindex=1;

while($dayindex<=$daynum){

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

for($i=1;$i<=7;$i++){//Loop to output 7-day information

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

//'2014-10-1'(pass in such a string)$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. Process the information of the previous and next month and the previous and next year

$ 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;//Previous year

$nexty=$year+1;//Next year

//Hyperlink

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

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

echo "&lt ;font face='official script'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>


Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template