2

这是我第一次提出问题,所以如果我做错了,请考虑到这一点。请仔细查看并解释我哪里出错了。
我可以在日历行的当前月份的第一周显示上个月的结束日期。但我需要在锚标记中包含一个查询字符串,该字符串与当前的 $print_date 相呼应。这些是我已经尝试过但没有成功的不同方法。日期格式为“YYYY-MD”

while ( $start_point > 0 ) 
{   
    // Returns what day of the week 'w' (numeric 0-6), using the date function.
    $day_of_week = date('w', mktime(0, 0, 0, $month, 1, $year));    
    // To get the last Sunday of the previous month use:
    $sun_prev_month = date('d', mktime(0, 0, 0, $month, (1 - $day_of_week), $year));
    // Fills the dates, starting on Sunday for the end of previous month
    $print_date = $sun_prev_month;      
    for ($i = 0; $i < $day_of_week; ++$i)
    {                       
        //echo '<td class="shade"><a href="/~seeleyja/CSCI-2910/calendar4.php?date=' . $year . '-' . ($month-1) . '-' . $print_date  . '">'. $print_date . '</a></td>';
                ?>
        <td><a href="/~seeleyja/CSCI-2910/calendar4.php?<?=htmlspecialchars($prev_month);?>"> $print_date </a></td>;
        <?php
        //echo '<td class="shade"><a href="/~seeleyja/CSCI-2910/calendar4.php?date=$prev_month">'. $print_date . '</a></td>';
        //echo '<td class="shade"><a href="/~seeleyja/CSCI-2910/calendar4.php?date=' . $year . '-' . ($month-1) . '-' . $print_date . '">'. $print_date . '</a></td>';
        --$start_point;
        $print_date++;                      
        $day_of_week_counter++;                             
    }
}
4

1 回答 1

0

您当前正在使用未定义的变量 $prev_month,并且忘记了 URL 中的“日期”参数。您是否可能打算使用 $sun_prev_month 或 $print_date?

于 2013-02-16T06:22:52.420 回答