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. Quote Link to comment 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? Quote Link to comment Share on other sites More sharing options...
Eiseth Posted June 4, 2013 Share Posted June 4, 2013 Use loop Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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> Quote Link to comment 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.