Difficulty with Weekly Agenda Display

Asked

Viewed 52 times

1

I am trying to create a weekly schedule that displays the scheduled classes of each day and time, and also leaves the unscheduled schedules vacant. I developed the following code to record all class dates. However, I cannot present the search results in a table, in the form of a weekly schedule divided into days and times...

$dtv = explode('/', $resul['dia']);
for($i=1;$i<=26;$i++){
$proxdia = $dtv[2]+7;
if(($dtv[0]%4==0 && $dtv[0]%100 != 0)||($dtv[0]%400==0)):
    if($dtv[1] == 2):
        if($proxdia > 29):
            $sobra = 29 - $dtv[2];
            $sobra = 7 - $sobra;
            $proxdia = $sobra;
            $dtv[2] = $proxdia;
            $dtv[1] = $dtv[1]+1;
        else:
            $dtv[2] = $proxdia;
        endif;
    endif;
else:
    if($dtv[1] == 2):
        if($proxdia > 28):
            $sobra = 28 - $dtv[2];
            $sobra = 7 - $sobra;
            $proxdia = $sobra;
            $dtv[2] = $proxdia;
            $dtv[1] = $dtv[1]+1;
        else:
            $dtv[2] = $proxdia;
        endif;
    endif;
endif;
if($dtv[1] == 4 || $dtv[1] == 6 || $dtv[1] == 9 || $dtv[1] == 11):
    if($proxdia > 30):
        $sobra = 30 - $dtv[2];
        $sobra = 7 - $sobra;
        $proxdia = $sobra;
        $dtv[2] = $proxdia;
        $dtv[1] = $dtv[1]+1;
    else:
        $dtv[2] = $proxdia;
    endif;
else:
    if($proxdia > 31):
        $sobra = 31 - $dtv[2];
        $sobra = 7 - $sobra;
        $proxdia = $sobra;
        $dtv[2] = $proxdia;
        $dtv[1] = $dtv[1]+1;
    else:
        $dtv[2] = $proxdia;
    endif;
endif;
if($dtv[1]>12):
    $dtv[1]=1;
    $dtv[0]=$dtv[0]+1;
endif;
$dataaula = $dtv[0] . '-' . $dtv[1] . '-' . $dtv[2];
if($dataaula):
    $dtaula = conectar()->prepare('insert into descriaula
        set aula=?, dataaula=?');
    $retorno4 = $dtaula->execute(array(
        $idaula,
        $dataaula));
else:
    echo "Erro ao cadastrar aula";
endif;
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.