Esci Villagonzalo Morales Esci Villagonzalo Morales - 3 years ago 84
PHP Question

How can I display all the data from a table?

How can I display all the data from a table inside a table tag using loops?
Here is my code:

<table width="380px">
<tr>
<td><?php echo $left_bread['recipe'];?></td>
<td><?php echo $left_bread['name'];?></td>
<td><?php echo $left_bread['scale_date'];?></td>
</tr>
</table>

Answer Source

i think your code is lacking..from what i see it lacks a foreach(). maybe you should try this,

<?php foreach($your_variable as $your_alias):?>
<table width="380px">
<tr>
    <td><?php echo $your_alias['recipe'];?></td>
    <td><?php echo $your_alias['name'];?></td>
    <td><?php echo $your_alias['scale_date'];?></td>
</tr>
</table>
<?php endforeach;?>

I think that's it, if what you want is display data dynamically from a query, then this will do, knowing that $your_variable contains a query which will get recipe,name and scale_date. :)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download