loganbest Posted August 11, 2010 Share Posted August 11, 2010 I have a while loop nested inside of another while loop to populate a drop-down select box for each result from the parent while loop. The inner loop only gets run once though... any ideas on how to fix this without it being extremely data heavy? Quote Link to comment https://forums.phpfreaks.com/topic/210407-nested-while-loop-not-working/ Share on other sites More sharing options...
JasonLewis Posted August 11, 2010 Share Posted August 11, 2010 while(true) It's kind of hard to say, without seeing your code... Quote Link to comment https://forums.phpfreaks.com/topic/210407-nested-while-loop-not-working/#findComment-1097937 Share on other sites More sharing options...
sasa Posted August 11, 2010 Share Posted August 11, 2010 use mysql_data_seek($result, 0); before inside loop to move index to start of $result Quote Link to comment https://forums.phpfreaks.com/topic/210407-nested-while-loop-not-working/#findComment-1097947 Share on other sites More sharing options...
RussellReal Posted August 11, 2010 Share Posted August 11, 2010 foreach ($dropDowns as $name => $v) { echo "<select name='{$name}'>"; foreach ($v as $opHTMLValue => $optValue) { echo "<option value='{$optHTMLValue}'>{$optValue}</option>"; } echo "</select>"; } this will expect an array structured like this.. array( [places] => array( [myroom] => My Betroom!, [bathroom] => The Bathroom! ), [names] => array( [names1] => Tanya, [names2] => Jane ) ) Quote Link to comment https://forums.phpfreaks.com/topic/210407-nested-while-loop-not-working/#findComment-1097950 Share on other sites More sharing options...
loganbest Posted August 12, 2010 Author Share Posted August 12, 2010 Data seek worked perfectly... I had that but I had it after the inner loop which I guess made it defective. Quote Link to comment https://forums.phpfreaks.com/topic/210407-nested-while-loop-not-working/#findComment-1098345 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.