I have a dynamic HTML table that has the following result:
ThecolumnsPortugueseandMathematics,comefromthedatabaseandaredynamic,thatis,theycancontainmoresubjects.ThesamehappenswiththeStudentscolumn,whichisalsodynamicandcomesfromthedatabase.
PleasenotethatFernandoPessoa'sgradesare:Portuguese11andMathematics12andSantosDumontisPortuguese13andMathematics14.
Togeneratethistable,Ididthefollowing.(correctmeifI'mdonewrong):
publicfunctionmateriasNotas($idEscolas,$idTurmas){.....$listar="<table class=\"table table-bordered\">
<thead>
<tr>
<th style='background-color: #4682B4; color: #FFF; text-align: center'>Alunos</th>";
while($jmListar = mysqli_fetch_object($sqlListar)){
$listar .= "<th style='background-color: #4682B4; color: #FFF; text-align: center'>".$jmListar->Materias."</th>";
}
$listar .= "<th style='background-color: #4682B4; color: #FFF; text-align: center'>Boletim</th>
</tr>
</thead>";
$sqlAlunos = mysqli_query($this->conexao,"SELECT * FROM pe_cadastros_alunos WHERE IdEscolas = '".$idEscolas."' AND IdTurmas = '".$idTurmas."';");
while($jmAlunos = mysqli_fetch_object($sqlAlunos)){
$listar .= "<tbody>";
$listar .= "<td style='background-color: #B0C4DE'><input type='text' name='Alunos[]' value='".$jmAlunos->NomeCompleto."' style='border: 0; background-color: #B0C4DE;' readonly></td>";
//$i = 1;
$sqlMat = mysqli_query($this->conexao,"SELECT * FROM pe_materias WHERE IdEscolas = '".$idEscolas."' AND IdSeries = '".$jmTurmas->Series."';");
while($jmMat = mysqli_fetch_object($sqlMat)){
$listar .= "<td><div align='center'><input type='hidden' name='Materias[]' value='".$jmMat->Materias."'><input type='text' name='Notas[]' placeholder='Nota' style='width: 100px'></div></td>";
}
$listar .= "<td><div align='center'><button class='btn btn-success btn-xs'><i class=\"fa fa-print fa-lg\" aria-hidden=\"true\"></i> Imprimir</button> <button class='btn btn-success btn-xs'><i class=\"fa fa-envelope fa-lg\" aria-hidden=\"true\"></i> E-mail</button> <button class='btn btn-success btn-xs'><i class=\"fa fa-download fa-lg\" aria-hidden=\"true\"></i> Baixar</button></div></td>";
$listar .= "</tbody>";
}
$listar .= "</table>";
return $listar;
}
The problem is the time to register in the database, as it is returning me this way:
Note that the names are not beating with the notes quoted above, ie in the second line was to stay Fernando Pessoa and Santos Dumont was to stay on the third and fourth lines.
Iamregisteringthisway:
publicfunctioncadastrarNotasAlunos($idEscola,$aluno,$bimestre,$materias,$notas,$situacao){....for($i=0;$i<=count($notas)-1;$i++){mysqli_query($this->conexao,"INSERT INTO pe_notas_alunos VALUES(null,'".$idEscola."','".$aluno[$i]."','".$materias[$i]."','".$notas[$i]."','". $bimestre."','".$situacao."');");
}
}
How would I do to have the names registered according to your notes?