I am making a code where I select information from the database and feed an array, in the sequence I am trying to use the contents of this array to compare with other information and process the rest of the code.
But I'm having trouble getting the data from within the array, below my code:
<?php
$fuso = mktime(date("H")-3, date("i"), 0);
$hoje = gmdate("Y-m-d", $fuso);
//$resultado_array = array(); //sem o array
$agendamentos = $dbh->query("SELECT * FROM agenda WHERE data_agendamento='$hoje'");
while($row = $agendamentos->fetch(PDO::FETCH_ASSOC)) {
if ($row['hora_agendamento'] == "08:00:00") { //agora com $row
echo '<tr>';
echo '<td>' . $row['hora_agendamento'] . '</td>';
echo '<td>' . $row['id_paciente'] . '</td>';
echo '<td>' . $row['observacao'] . '</td>';
echo '<td>' . $row['id_agendamento'] . '</td>';
echo '<td>Editar</td>';
echo '</tr>';
}
else {
echo '<tr>';
echo '<td>08:00:00</td>';
echo '<td></td>';
echo '<td></td>';
echo '<td></td>';
echo '<td>Editar</td>';
echo '</tr>';
}
if ($row['hora_agendamento'] == "09:00:00") { //agora com $row
echo '<tr>';
echo '<td>' . $row['hora_agendamento'] . '</td>';
echo '<td>' . $row['id_paciente'] . '</td>';
echo '<td>' . $row['observacao'] . '</td>';
echo '<td>' . $row['id_agendamento'] . '</td>';
echo '<td>Editar</td>';
echo '</tr>';
}
else {
echo '<tr>';
echo '<td>09:00:00</td>';
echo '<td></td>';
echo '<td></td>';
echo '<td></td>';
echo '<td>Editar</td>';
echo '</tr>';
}
} //while agora só termina aqui
echo '</tbody></table>';
?>
In case if I find inside the array the string there determined it should fill in the data below, but at the beginning if it already presents the error:
Notice: Undefined index: schedule_time in C: \ wamp64 \ www \ schedules \ index.php on line 29
Clearly because I can not get the data inside the array, how do I proceed?