【发布时间】:2016-04-05 21:04:32
【问题描述】:
问题是当我输入第 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>";
}
}
}
}
} ?>
【问题讨论】:
-
$joinmonth 和 $joinyear 的值????
-
从两个文本框中输入
-
请提供测试值???加入月 = 12,加入年 = 2015 ????
-
@devpro 我更新了代码并添加了 html 部分......是的,您可以参加第 12 个月和 2015 年加入测试
-
是的,我已经检查并更新了答案