问题是当我进入第12个月& 2015年,它打印到2016年的12个月而不是第1个月。 (任何语言的提示都会很棒,因为它是关于逻辑的,所以我在标签中添加了C& JAVA) 这是代码
<form method="GET" action="<?php $_PHP_SELF ?>">
<table>
<tr>
<td><input type="text" name="year" value="Enter Year" /></td>
<td><input type="text" name="month" value="Enter MOnth" /></td>
<td><input type="submit" value="Submit" name="submit"/></td>
</tr>
</table>
</form>
<?php $joinmonth=$_GET['month'];
$joinyear=$_GET['year'];
$currentmonth=date('m');
$currentyear=date('Y');
if(isset($_GET['submit']))
{
for($i=$joinyear;$i<=$currentyear;$i++)
{
for ($j = $joinmonth; $j <=12 ; $j++) {
a:
if ($i <= $currentyear) {
if ($j == 12) {
echo "MOnth ".$j." & year ".$i."<br><br>";
$j = 1;
$i++;
goto a;
}
else {
echo "MOnth ".$j." & year ".$i."<br><br>";
}
}
}
}
} ?>
答案 0 :(得分:0)
试试这个会给你的加入月份和年份以及月份和年份:
$joinmonth=12;
$joinyear=2015;
$currentmonth=date('m');
$currentyear=date('Y');
if(isset($_GET['submit']))
{
for($i=$joinyear;$i<=$currentyear;$i++)
{
for ($j = $joinmonth; $j <=12 ; $j++)
{
a:
if ($i <= $currentyear)
{
if ($j == 12)
{
echo "MOnth ".$j." & year ".$i."<br><br>";
$j = 1;
$i++;
goto a;
}
elseif($j == $currentmonth)
{
echo "MOnth ".$j." & year ".$i."<br><br>";
}
}
return;
}
}
}