I have the following table:
ButIneedtoincludethematerialswithintherespectivefieldsofthedayoftheweekthatreflectstheschedules.Forthis,I'musing02methodsthatcreatetheimagebelow:
publicfunctioncadastrarHEscolas($idEscolas,$idGrades){...$this->comboboxGrade($jmVisualizar->IdHorarios,$idEscolas);...}publicfunctioncomboboxGrade($idHorarios,$idEscolas){$sqlListar=mysqli_query($this->conexao,"SELECT * FROM pe_materias WHERE IdEscolas = '".$idEscolas."';");
$listar = "<select name='Materias[]' id='materias' class='form-control'>";
$listar .= "<option value='Selecione'>Matéria</option>";
while($jmListar = mysqli_fetch_object($sqlListar)){
$listar .= "<option value='".$jmListar->Materias."_".$idHorarios."'>".$jmListar->Materias."</option>";
}
$listar .= "</select>";
return $listar;
}
So far so good, but for me to store inside the IdHorarios, I include in the second method, in the option attribute the following line:
$listar .= "<option value='".$jmListar->Materias."_".$idHorarios."'>".$jmListar->Materias."</option>";
The above code returns the Id of the Schedules table and the Matter, separated by the underline.
And when I click on register, I use the method below to register in the database:
public function cadastrarGradeMaterias($materias){
// $materias me retorna portugues_1, matematica_1, fisica_2, etc.
for($m = 0; $m < count($materias); $m++){
$mat = explode("_",$materias);
$sqlCadastrar = mysqli_query($this->conexao,"UPDATE tabela SET Segunda - '', Terca = '', Quarta = '', Quinta = '', Sexta = '', Sabado = '' WHERE IdHorario = ''");
}
}
Here's the problem. How would I do to give an explode and include within the query the selected fields and their respective ID?