0
<?php
$listar = new FuncionarioDAO();
$resultTudo = $listar->listar();
$results = new FuncionarioDAO();
$results = $results->retornaEmpresa();
while($row = $resultTudo->fetch_assoc()) {?>
<tr>
<td><?= $row['id']?></td>
<?php
foreach($results as $values) {?>
<td><?php if($values['id'] == $row['id_empresa']){echo $values['nome']; break;}?></td>
<?php }?>
<td><?= $row['nome']?></td>
<td><?= $row['sobrenome']?></td>
<td><?= $row['telefone']?></td>
<td><a class="label label-warning" href="<?= "funcionario-atualizar?x=".$row['id'];?>">editar</a></td>
<td><a href="<?= "funcionario-remover?x=".$row['id'];?>" class="label label-danger">remover</a></td>
</tr>
<?php }if($resultTudo->num_rows == 0){
print("<h3 class='btn btn-warning'>Nenhum produto cadastrado ainda</h1>");
}?>
There’s a foreach there in the middle of the table line that doesn’t make any sense. And it would be nice to replace this open and close PHP stack with "echo", so it makes it easier to read the code. Something else, use
<?=
is to ask your application to work in one place only. This is kind of complicated.– Bacco
There is an employee table q relates to a company table, the employee table has the company id then I put the company name to the list. But so was the table.
– Paulo Costa
select * from employee Join company
– Paulo Costa
I did to go through the result to find the value and print.
– Paulo Costa
Could do
$results[0]['nome']
and take out theforeach
completely, since you want to get only one result, but anyway you could bring this field of a JOIN, with only one query. Take a look at the table overall, should have a<tr>
with<td>
more than others<tr>
's.– Thomas