Hello there,
I have a BIG bug in my code! I can't find out where it comes from. Could someone help me please?
It's a calendar. You see the current date and when clicking on an other day of the week it should change the date, this works, BUT if you change the date again you don't geet the right day.
Could someone help me please? 😕
<?php
$get_day = date("N");
$get_date_day = date("d");
$get_date_mth = date("m");
$get_date_yea = date("Y");
if($getdate=="" | $getdate=="-1") {
$set_day_bg['' . $get_day] = "bgcolor=\"$layout_list_color2\"";
}
if(empty($c)) {
echo"Debug: IF THEN<br>";
$get_date = date("Y-m-d");
$get_date_spec = explode("-",$get_date);
$get_p_week = "0";
$get_m_week = "0";
}
else {
echo"Debug: ELSE<br>";
$get_p_week = ($getdate+7);
$get_m_week = ($getdate-7);
$getweek = time() + (($get_p_week) * 86400);
$get_date = date("Y-m-d",$getweek);
$get_date_spec = explode("-",$get_date);
}
echo"
<table>
<tr>
<td><b>" . date("F d, Y", mktime (0,0,0,$get_date_spec[1],$get_date_spec[2],$get_date_spec[0])) . "</b> </td>
";
$i = 1;
$j = -$get_day;
while ($i <= 7):
$j=$j+1;
if(empty($c)) { $k = $get_p_week+$j-7; } else { $k = $get_p_week+$j-7; }
echo" <td " . $set_day_bg['' . $i] . "><a target=\"_self\" href=\"$PHP_SELF?getdate=$k&c=gw\">" . date("l", mktime (0,0,0,$get_date_mth,$get_date_day+$j,$get_date_yea)) . "</a></td>\n";
$i++;
endwhile;
echo"
<td><a target=\"_self\" href=\"$PHP_SELF?getdate=$get_m_week&c=gw\"> - </a></td>
<td><a target=\"_self\" href=\"$PHP_SELF?getdate=$get_p_week&c=gw\"> + </a></td>
</tr>
</table>
";
?>