Jeneca Posted February 9, 2012 Share Posted February 9, 2012 I have in my database a list of store names, And it takes time to input one by one their names in a drop down list, so I need to loop, How to do this..? Link to comment Share on other sites More sharing options...
TheGallery Posted February 9, 2012 Share Posted February 9, 2012 This should actually go to the PHP forum (from your Languages information in your profile i assume you use PHP and not ASP). Anyway here is the way i'd dynamically create the list. <select> <?php //Let's assume you have a class or a function that returns and stores the store names in an array, using a function in this example $store_names = get_store_names(); $max_stores = count($store_names) // Gets the number of the array elements for($i = 0; $i < $max_stores; $i++) echo '<option value="store' . $i+1 . '">' . $store_names[$i] . '</option>'; ?></select> Link to comment Share on other sites More sharing options...
Ingolme Posted February 9, 2012 Share Posted February 9, 2012 There aready is a thread in the PHP forum, so I'll close this one. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.