View Single Post
Old 07-05-2012, 08:13 AM   #1 (permalink)
ban007
The Visitor
 
Join Date: Jul 2012
Posts: 2
Thanks: 0
ban007 is on a distinguished road
Application Fetching from MySQL to multiple rows in a table

Hi there!
I'm trying to fetch data from my Mysql db. The table has four columns. I need to put in each row a select form with db data inside. Using while() I get the data but only for the first row. Can anyone help me to get the select values/data in all rows?
The screenshot: http://ScrnSht.com/whkycz
The code in pastebin: http://pastebin.com/FcUK2twv
or here:
<?php
while ($item2 = $listado->fetch()) {
?>
<tr>
<td>Carril nš: <?php echo $item2['idCarrilTabaco'] ?><td>
<td>
<select name="descripcion" size ="1">
<?php while ($tabacos1 = $tabacos->fetch()) {?>
<option value='<?php echo $tabacos1['idTabaco']?>'><?php echo $tabacos1['descripcion']?></option>
<?php } ?>
</select>
</td>
<td><?php echo $item2['Capacidad'] ?></td>
<td><?php echo $item2['Cantidad'] ?></td>
</tr>
<?php
}
?>

Thanks all! Ban.

Solution: I created a variable using fetchAll() out of the while scope. But is there another way to do it?
It looks now like: http://pastebin.com/y1MGGT8V

Last edited by ban007 : 07-05-2012 at 08:27 AM. Reason: Solution found!!
ban007 is offline  
Reply With Quote