0
I have a school schedule registration system that’s on this model:
I need to include in the database that’s with this structure:
Ex.:
From 07:00 to 07:05, I chose the following subjects: Mathematics, Portuguese and Biology.
And in the hours from 09:00 to 09:25, I chose the subjects: Philosophy, Chemistry and Arts.
But I’m not getting it.
See the result
I’m doing it this way:
Taking data from the form
$horarioEntrada = $_POST["HorarioEntrada"];
$horarioSaida = $_POST["HorarioSaida"];
$materias = $_POST["Materias"];
echo $metodos->cadastrarGradeEscolar($horarioEntrada,$horarioSaida,$materias);
Schedules
<select class="form-control" name="HorarioEntrada[]" style="width:90px">
<?php
for($horarioInicio = 7; $horarioInicio <= 22; $horarioInicio++){
$horarioInicio = ($horarioInicio < 10)?("0".$horarioInicio):($horarioInicio);
?>
<option value="<?php echo $horarioInicio; ?>:00"><?php echo $horarioInicio; ?>:00</option>
<?php } ?>
</select>
<span class="input-group-addon" style="background-color: #FAFAFA">às</span>
<select class="form-control" name="HorarioSaida[]" style="width:90px">
<?php
$horaFinal = "07:00";
for($horaFim = 0; $horaFim < 180; $horaFim++){
$horaFinal = date('H:i', strtotime('+5 minute', strtotime($horaFinal)));
?>
<option value="<?php echo $horaFinal; ?>"><?php echo $horaFinal; ?></option>
<?php } ?>
?>
</select>
Matters
$sqlListar = mysqli_query($this->conexao,"SELECT * FROM pe_materias WHERE IdEscolas = '".$idEscolas."';");
$listar = "<select name='Materias[]' class='form-control'>";
$listar .= "<option value='Selecione'>Matéria</option>";
while($jmListar = mysqli_fetch_object($sqlListar)){
$listar .= "<option value='".$diaMateria."_".$jmListar->IdMaterias."'>".$jmListar->Materias."</option>";
}
$listar .= "</select>";
return $listar;
}
Registration method Choose()
public function cadastrarGradeEscolar($horarioEntrada,$horarioSaida,$materias){
foreach($horarioEntrada as $valor => $horaE){
for($i = 0; $i < count($materias); $i++){
if($materias[$i] != "Selecione"){
echo $horaE . "= " .$materias[$i];
}
}
}
}
what mistake you see?
– FBidu
Hello Fbidu. Not fitting in the table layout. I edited my post to show the result.
– user24136
Improve your explanation, what your expectation?
– ClaudioLopes
Hello Claudio. My expectation is: I need that when registering the schedule grid (figure 1), it is stored in the database according to the layout of the table (figure 2), but I am not able to, because it is registered in all columns (figure 3).
– user24136