Calendar two or more weeks

I have this calendar code i came up with after looking if i want to put in two or more weeks how can i do that? Think this works but not somone can help? Swiched but somthing seems to be missing.


$year = 2018;
$curMonth = date('06', $today);
$curDay = date("d", $today);

if ($week_number = 23){
if ($week_number = 24){
for($day=1; $day<=7; $day++){
    $datetime = strtotime($year."W". $week_number. $day);
    $month = date('m', $datetime);
    $daysnumber = date('d', $datetime);
    if ($curMonth === $month && $daysnumber === $curDay) {
        echo"<td bgcolor='#ff0000'>$daysnumber</td>" ;
    } elseif ($curMonth === $month) {
        echo"<td bgcolor='#ffffff'>$daysnumber</td>" ;
    } else {
        echo"<td bgcolor='#ffffff'></td>" ;

What is your intention with these two lines of code?

if ($week_number = 23){
if ($week_number = 24){

If you’re intending to check the value of the week number, where is that value being set? And this is not the way to check a value, it’s a way to assign it. And if you did intend to be doing a comparison rather than an assignment, then your two lines won’t work because if it gets through the first one, it won’t get through the second one.

As for the original question

for($day=1; $day<=7; $day++){

Is it just as simple as extending this loop to cover more than seven days? Would that achieve what you need?

Thinking the the first two if to in the loop but not work? Or i need to add somthing to the last part of the code. Don t know what to do.

Sorry, can you expand on that, I’m not quite sure what you mean?

Have a very careful look at those two lines of code, and then see what I mean about the difference between assignment operators and comparison operators. If you intend those to be comparing values, they have a serious typo. And I don’t see in your code where you ever set a value for $week_number, if they are intended to be comparisons. If they are intended to be assignments, I’m struggling to see why you have them both.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.