TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 07-05-2012, 08:13 AM   #1 (permalink)
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
Old 07-05-2012, 02:00 PM   #2 (permalink)
The Addict
 
tony's Avatar
 
Join Date: Aug 2008
Posts: 336
Thanks: 8
tony is on a distinguished road
Default

It's hard to know why the first pastebin wasn't working if we don't know how the variables $listado or $tabacos were created.

P.D. Usaste mysql_query o otra funcion o clase?

Last edited by tony : 07-05-2012 at 02:01 PM. Reason: a little spanish friendliness
tony is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
feedback on my class please frostyboy33 Advanced PHP Programming 7 10-22-2012 09:12 AM
save a PDF file inside a mySQL table pipesportugal Absolute Beginners 1 07-11-2010 09:54 PM
Databse structure Village Idiot TalkPHP Developer Team 3 01-16-2009 10:31 PM
This project has begun! Village Idiot TalkPHP Developer Team 40 01-01-2009 04:29 AM


All times are GMT. The time now is 08:11 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design