0
So guys, I have this table with information like: id, student, computer, date of registration, time of entry, time of departure and reason, but in student and computer I want to show the name/ description and not the id. Follow my code there.
Student and computer are from another table
public function buscaTodos() {
$sql = "SELECT * FROM " . $this->tabela;
$sqle = $this->con->query($sql);
$dados = $sqle->fetchAll(PDO::FETCH_ASSOC);
return $dados;
}
$registro = new Registro();
$dados = $registro->buscaTodos();
<table class='table][1]][1] table-bordered table-striped'>
<tr>
<th>ID</th>
<th>Aluno</th>
<th>Computador</th>
<th>Data</th>
<th>Hora de Entrada</th>
<th>Hora de Saída</th>
<th>Motivo</th>
<th>Opções</th>
</tr>
<?php
foreach($dados as $r){
$id=$r['id'];
$aluno=$r['id_aluno'];
$computador=$r['id_computador'];
$dt_registro = $r['dt_registro'];
$hr_entrada = $r['hr_entrada'];
$hr_saida = $r['hr_saida'];
$motivo = $r['motivo'];
?>
<tr>
<td><?=$id?></td>
<td><?=$aluno?></td>
<td><?=$computador?></td>
<td><?=$dt_registro?></td>
<td><?=$hr_entrada?></td>
<td><?=$hr_saida?></td>
<td><?=$motivo?></td>
</tr>
<?php } ?>
</table>
What is the question?
– Lucas Torres
young person, if the fields Name and description are in the same table, just change in $r['id_student'] for $r['student name'] for example, the code is very simple but you need to know the structure of the table
– Rovann Linhalis
are in another table
– user73981
I don’t think the fields
aluno
andcomputador
are populated in this table. If they are in another, you will need to do ajoin
, perhaps using theid
ofaluno
.– Leonardo Pessoa