Php 我必须打印从输入的月份/年份到当前月份/年份的月份和年份

Php 我必须打印从输入的月份/年份到当前月份/年份的月份和年份,php,html,date,Php,Html,Date,问题是,当我输入2015年12月和2015年12月时,它打印到2016年的12个月,而不是第一个月。 任何语言中的提示都会很棒,因为它都是关于逻辑的,所以我在标记中添加了C&JAVA 这是密码 <form method="GET" action="<?php $_PHP_SELF ?>"> <table> <tr> <td><input type="text"

问题是,当我输入2015年12月和2015年12月时,它打印到2016年的12个月,而不是第一个月。 任何语言中的提示都会很棒,因为它都是关于逻辑的,所以我在标记中添加了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>";
                }
            }
        }
    }
} ?>

试试这个,它会给你的加入月和年和ist月和年:

$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;                
        }
    }
}

从两个文本框中输入$joinmonth和$joinyear的值,我们将输入它。请提供测试值???joinmonth=12,joinyear=2015???@devpro i更新了代码并添加了html部分…&是的,你可以拿join month 12和join year 2015进行测试是的,我已经检查过了,并更新了一个回答它只有12个月没有其他的,这是我用我的代码得到的相同输出,这是错误的…正确的输出将是month 12和year 2015…month 01和year 2016…因为当前年份是2016,月份是201601@SSangeet:预期结果是否相同?2记录加入信息当前信息??阅读问题dude,我们必须打印从输入的月/年到currenttoday的月/年…顺便说一下,我找到了答案