oceans Posted May 2, 2007 Share Posted May 2, 2007 Dynamically create List value entries. Please advice me on how to create list box entries at run time Say: $var1=1; $var2=2; My list box is empty right now <select name="Combo1" id="Combo1"> </select> Link to comment https://forums.phpfreaks.com/topic/49594-solved-dynamically-create-list-value-entries/ Share on other sites More sharing options...
trq Posted May 2, 2007 Share Posted May 2, 2007 Are the entries coming from a db or where? If so, your last post (the one I helped you with) should be a clear enough example. Link to comment https://forums.phpfreaks.com/topic/49594-solved-dynamically-create-list-value-entries/#findComment-243171 Share on other sites More sharing options...
oceans Posted May 2, 2007 Author Share Posted May 2, 2007 Thrope, I understood your example, this time I want to populate list box, I agree the data comes after quary, just to modularise i am putting as variable in this example. please advice, thaks. Link to comment https://forums.phpfreaks.com/topic/49594-solved-dynamically-create-list-value-entries/#findComment-243172 Share on other sites More sharing options...
trq Posted May 2, 2007 Share Posted May 2, 2007 Sorry, I'm not sure I follow your last post. I'll just show you an example using an array and a foreach loop. <?php $vals = array('foo','boo','bar'); echo "<select name=\"Combo1\" id=\"Combo1\">"; foreach ($vals as $v) { echo " <option value=\"$v\">$v</option>"; } echo "</select>"; ?> Link to comment https://forums.phpfreaks.com/topic/49594-solved-dynamically-create-list-value-entries/#findComment-243175 Share on other sites More sharing options...
oceans Posted May 2, 2007 Author Share Posted May 2, 2007 Thanks, it works fine. Link to comment https://forums.phpfreaks.com/topic/49594-solved-dynamically-create-list-value-entries/#findComment-243177 Share on other sites More sharing options...
oceans Posted May 2, 2007 Author Share Posted May 2, 2007 can any one halp me how can I insert result variable from quary in echo " <option value=\"$v\">$v</option>"; I have to change "$v", but somthing is hitting there Link to comment https://forums.phpfreaks.com/topic/49594-solved-dynamically-create-list-value-entries/#findComment-243235 Share on other sites More sharing options...
oceans Posted May 2, 2007 Author Share Posted May 2, 2007 thanks i fixed it Link to comment https://forums.phpfreaks.com/topic/49594-solved-dynamically-create-list-value-entries/#findComment-243240 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.