-1
I’m trying to list in the same element select of html the results of the consultation of different tables, but I’m not getting.
Follow down the code so someone can tell me where I’m going wrong.
<div class="form-group">
<label>Selecione a turma:</label>
<select name="id_disciplina_turma_facul">
<?php
$consulta = \MySql::conectar()->prepare("SELECT tb_turma_facul.id_turma_facul as turma,
tb_turma_facul.id_disciplina_turma_facul,
tb_disciplina_facul.id_discip_facul,
tb_disciplina_facul.nome_discip_facul as dnome,
tb_turma_facul.id_professor_turma_facul,
tb_professor_facul.nome_professor as pnome
FROM tb_turma_facul
INNER JOIN (tb_disciplina_facul, tb_professor_facul)
ON (tb_turma_facul.id_disciplina_turma_facul =
tb_disciplina_facul.id_discip_facul
AND tb_turma_facul.id_professor_turma_facul =
tb_professor_facul.cpf_professor)");
$consulta->execute();
$consulta = $consulta->fetchAll();
foreach ($consulta as $key => $value) {
?>
<option value="<?php echo $value['dnome'] ?>">
<?php echo $value['pnome']; ?>
</option>
<?php } ?>
</select>
</div><!--form-group-->
<div class="form-group">
<input type="submit" name="acao" value="Matricular em turma">
</div><!--form-group-->
Table columns are described below.
Being, that the table turma owns the foreign keys of the tables disciplina and professor.
Table columns tb_disciplina_facul:
id_discip_faculnome_discip_faculcarga_horaria_discip_facul
Table columns tb_professor_facul:
nome_professorendereco_professorcomplemento_professorcep_professorbairro_professorcidade_professorestado_professortelefone_professorformacao_professortitulacao_professor
Table columns tb_turma_facul:
id_turma_id_disciplina_turma_faculid_professor_turma_facul


How many tables are there, friend? I can make a basic example and Oce adapts in how many cases it is best
– Risk
Note that the columns of each table are described below the code, so you can base yourself to look similar to mine.
– Fabiano Sousa
There are 3 tables, the first of the subjects, the second of the teachers and the third is called class. The latter will possess the foreign keys of the first two.
– Fabiano Sousa