Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Nested While loop

Status
Not open for further replies.

dstefani

Programmer
Aug 26, 2002
2
US
Hello,

I am trying to build rows from a query (easy)
But in each row, I need to have a form that contains
a select list. The select list has to be filled by
another query.

Maybe I'm just too tierd, how can I pass all of the
option tags to my row query?

while(build this row from a query)
{
build a select statement and fill the options list
with dynamic data (a complete list, not just one at
a time like the parent while is doing).
<option>dynamic element</option>
<option>dynamic element</option>
<option>dynamic element</option>
<option>dynamic element</option>
Done
}

Thanks!
Don

Working sick stinks! dstefani (Don)
 
Something like this maybe?
Code:
$result = mysql_query(&quot;SELECT * FROM sometable&quot;) or die(&quot;Couldn't query: &quot; . mysql_error());
while ($row = mysql_fetch_assoc($result))
{
    $result2 = mysql_query(&quot;SELECT OptionsID, OptionsTitle FROM options WHERE SelectID='&quot; . $row['ID'] . &quot;'&quot;) or die(&quot;Couldn't query: &quot; . mysql_error());
    echo &quot;<select name=\&quot;&quot; . $row['Name'] . &quot;\&quot;>&quot;;
    while ($row2 = mysql_fetch_assoc($result2))
    {
        echo &quot;<option value=\&quot;&quot; . $row2['OptionsID'] . &quot;\&quot;>&quot; . $row2['OptionsTitle'] . &quot;</option>&quot;;
    }
    echo &quot;</select><br />&quot;;
}
I hope this gets you started :). //Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top