raysefo Posted June 4, 2013 Share Posted June 4, 2013 Hi, I would like to populate a drop down list box on my php page. How can I simply put a drop down on this php page? Best Regards. Link to comment https://forums.phpfreaks.com/topic/278760-how-to-implement-drop-down-list/ Share on other sites More sharing options...
davidannis Posted June 4, 2013 Share Posted June 4, 2013 Can you provide a little more detail on what you are trying to do? Where do you want the values to come from? Link to comment https://forums.phpfreaks.com/topic/278760-how-to-implement-drop-down-list/#findComment-1434035 Share on other sites More sharing options...
Eiseth Posted June 4, 2013 Share Posted June 4, 2013 Use loop Link to comment https://forums.phpfreaks.com/topic/278760-how-to-implement-drop-down-list/#findComment-1434057 Share on other sites More sharing options...
raysefo Posted June 5, 2013 Author Share Posted June 5, 2013 Hi, Lets say I have something like this ; <select name="games" size="3"> <option value="1">game1</option> <option value="2">game2</option> </select> I would like to select one of them from the list and get the value of the selected one. How can I do it? Best Regards. Link to comment https://forums.phpfreaks.com/topic/278760-how-to-implement-drop-down-list/#findComment-1434191 Share on other sites More sharing options...
cpd Posted June 5, 2013 Share Posted June 5, 2013 From what you've provided we can't give a 100% accurate answer, but assuming your form is set up to submit via POST you can access it in your PHP script using the $_POST super global. Link to comment https://forums.phpfreaks.com/topic/278760-how-to-implement-drop-down-list/#findComment-1434220 Share on other sites More sharing options...
Jessica Posted June 5, 2013 Share Posted June 5, 2013 Either you need to use the $_POST array, or you're trying to ask how to do chained selects using AJAX. Link to comment https://forums.phpfreaks.com/topic/278760-how-to-implement-drop-down-list/#findComment-1434234 Share on other sites More sharing options...
davidannis Posted June 5, 2013 Share Posted June 5, 2013 Try this: <?php if ($_POST['games']!='') echo '<h1>Last time you selected '.$_POST['games'].'</h1>'; ?> <form action="mypage.php" method="POST"> <p>Select a game:</p> <select name="games" size="3"> <option value="1">game1</option> <option value="2">game2</option> </select> <input type="submit"> </form> save it as mypage.php and run it a couple of times to see how it works. Link to comment https://forums.phpfreaks.com/topic/278760-how-to-implement-drop-down-list/#findComment-1434240 Share on other sites More sharing options...
johnmacd Posted June 13, 2013 Share Posted June 13, 2013 to add drop down in your php form first close php means ?> then write following code... <select name="games" > <option value="1">game1</option> <option value="2">game2</option> </select> Link to comment https://forums.phpfreaks.com/topic/278760-how-to-implement-drop-down-list/#findComment-1435681 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.