2
I need to assemble a schedule of days and events. When one of the days of the event is equal to the day of the table, it has to appear on the screen in the correct place. I’m already being able to compare and show, however, because the table is completely disassembled because of the algorithm that searches and traverses, I can’t make the table right ever!
Someone would know a solution to be able to mount the table by dribbling these tags?
Follow the code of the table:
<table class="table table-bordered">
<thead>
<tr>
<th><center>Turno \ Dia</center></th>
<?php
include_once 'classes/semestresclass.php';
if(!isset($_SESSION)) {session_start();}
$idSemestre = $_SESSION['SemestreGeral'];
$oSemestre = new semestresclass();
$oSemestre -> listarEdicao($idSemestre);
$array = mysql_fetch_array($oSemestre->retorno());
$start_date = $array['DataDeInicio'];
$end_date = $array['DataDeTermino'];
$inicio = new DateTime($start_date);
$fim = new DateTime($end_date);
$fim->modify('+1 day');
$interval = new DateInterval('P1D');
$periodo = new DatePeriod($inicio, $interval ,$fim);
foreach($periodo as $data){
echo '<th><p><center>'.$data->format("d/m/Y").'</p><p>'.$data->format("l").'</p></center></th>';
include_once 'classes/bancasclass.php';
if(!isset($_SESSION)) {session_start();}
$idSemestre = $_SESSION['SemestreGeral'];
$oBanca = new bancasclass();
$oBanca -> listar ($idSemestre);
while ($arrayBancas = mysql_fetch_array($oBanca->retorno())){
if (date('Y-m-d', strtotime($arrayBancas['dataHora'])) == $data->format('Y-m-d')) {
echo '<td>teste</td>';
}
}
}
?>
</table>
In this scheme I will also have schedules to organize this table... I’m trying to go in pieces, solve the day first and then the time, but maybe I’m going the wrong way, maybe I have to do everything together... In this case, the first column on the left will take the shifts 'morning', 'afternoon' and 'night' and, depending on the time of the event, put it according to the two axes.
I’m trying with a table, but solutions without table are also welcome!!
Table:
How should the table be presented? The way you explained it is a bit confusing.
– evsar3
The idea was to make a table like the one I put there as an image, where the data would be inserted in the respective places, according to the day and time...
– Alceu
I have not read the whole code but I assume it is enough to put <tr> before "while" and </tr> right at the end of the code, still inside the "foreach", because the foreach is what iterates the rows and while iterates the columns. But it has nonsense like the <tr> opened up there and there is no closure.. You must close it before the foreach. This first <tr></tr> I think should be the header, so inside it put the "static" part that is the days of the week (mon, Tue, Wed...).
– Daniel Omine
That answer, despite seem much more of what you need, can be of great value to you who, apparently, has not adopted (yet?) a template engine
– Bruno Augusto