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? 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... 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 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 ) ) 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. 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
Archived
This topic is now archived and is closed to further replies.