0
I have the following table:
However, I need to include the materials within the respective fields of the day of the week refeeded to the schedules. For this, I am using 02 methods that create the image below:
public function cadastrarHEscolas($idEscolas,$idGrades){
...
$this->comboboxGrade($jmVisualizar->IdHorarios,$idEscolas);
...
}
public function comboboxGrade($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 included in the second method, in the option attribute the following line:
$listar .= "<option value='".$jmListar->Materias."_".$idHorarios."'>".$jmListar->Materias."</option>";
The above code returns me the Table Id Times and Matter, separated by the underline.
And when I click to 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 what the problem is. How would I blow up and include within the query the selected fields and their respective ID?
How do you intend to register the days if you are not posting membership values between day, subject and time? You are only sending news and time. And in fact would have to send the matter the schedule and the day of the week to make this update.
– Rafael Salomão
Hello Rafael. The schedules are already registered, I just want to update the table including the materials that are going in the first block of code along with the table Id. Ex.: portugues_1, matematica_1, etc.
– user24136
In this case when you perform your explode by the underline in $mat[0] is the matter and $mat[1] the idHorario
– Rafael Salomão
this... only that according to the second image, has several fields referring to the schedules. That’s where I’m struggling. How do I change the table, including the materials, in the respective fields of the day of the week and time?
– user24136
That’s what my first message referred to... maybe you didn’t understand what I said. In fact I would make this option by assigning the name attribute as Materiassegunda[] , Materiasterca[] and so on because when posting the value you will know the day to matter and the idHorario
– Rafael Salomão
I get it... I’ll try here...
– user24136