rhyspaterson Posted May 28, 2007 Share Posted May 28, 2007 Hey lads just looking for a bit of help with this dynamic select list menu i'm building. $array can have any number of variables. i would like to list whatever is in it in a select menu. <?php $i = 0; echo "<select name=\"select\">\n"; while ($i <= $array){ ?><option value=""><?php echo $array[i];?></option> <?php $i = $i + 1; } ?> </select> At the moment it doesn't work obviously, haha. Any pointers? Quote Link to comment https://forums.phpfreaks.com/topic/53242-solved-dynamic-while-loop/ Share on other sites More sharing options...
eZe616 Posted May 28, 2007 Share Posted May 28, 2007 try <?php for($i=0;$i < count($array); $i++) { echo "<option value=\"".$i."\">".$array[$i]."</option"; } put that beetween the <select></select> tags Quote Link to comment https://forums.phpfreaks.com/topic/53242-solved-dynamic-while-loop/#findComment-263106 Share on other sites More sharing options...
rhyspaterson Posted May 28, 2007 Author Share Posted May 28, 2007 Ah perfect. Thanks! I love phpfreaks, haha. Donating tonight Quote Link to comment https://forums.phpfreaks.com/topic/53242-solved-dynamic-while-loop/#findComment-263107 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.