adzie Posted August 14, 2007 Share Posted August 14, 2007 hi guys I am working on a small script to load all members names into a drop down list, this I have acheived so far. What i'm looking to do is make this so that when I select a name from the list I have a submit button which opens up a member edit form which I have created. Below is where I'm at so far. Thanks for any help <?php //Connect to db include("connectdb.php"); $query = "SELECT name FROM members"; $result = mysql_query($query); echo "<select name=\"names\">\n"; while($row = mysql_fetch_array($result)) echo "<option name=\"".$row['name']."\">".$row['name']."</option>\n"; $name=$row = mysql_fetch_array($result); ?> Quote Link to comment https://forums.phpfreaks.com/topic/64895-drop-down-select/ Share on other sites More sharing options...
d22552000 Posted August 14, 2007 Share Posted August 14, 2007 I dont understnad what your question is... Quote Link to comment https://forums.phpfreaks.com/topic/64895-drop-down-select/#findComment-323776 Share on other sites More sharing options...
adzie Posted August 14, 2007 Author Share Posted August 14, 2007 sorry What I have so far is a drop down box of the members in my sql DB what i'd like to do it set it so that when I select a member from the list and click submit it opens another form with that members details. I have the other form created I just need to work out how to select a field and submit it Quote Link to comment https://forums.phpfreaks.com/topic/64895-drop-down-select/#findComment-323784 Share on other sites More sharing options...
lemmin Posted August 14, 2007 Share Posted August 14, 2007 Since I don't see a form tag I assume that is what you need. <form method=GET action="memberedit.php"> You can use GET or POST, doesn't matter. You will also need a submit button: <input type=submit value="edit"> </form> //close form tag, of course. After you have this code in that page, on your member edit page, you can access what was in the list with the post array: $_POST['names']. Quote Link to comment https://forums.phpfreaks.com/topic/64895-drop-down-select/#findComment-323788 Share on other sites More sharing options...
ViN86 Posted August 14, 2007 Share Posted August 14, 2007 just use $_REQUEST['names'] to get the value in the select box. make sure it's in a form. Quote Link to comment https://forums.phpfreaks.com/topic/64895-drop-down-select/#findComment-323819 Share on other sites More sharing options...
adzie Posted August 14, 2007 Author Share Posted August 14, 2007 I've edited thus far, can anyone point me in the right direction? <?php //Connect to db $_POST['name']. include("connectdb.php"); $query = "SELECT name FROM pilots"; $result = mysql_query($query); echo "<select name=\"names\">\n"; while($row = mysql_fetch_array($result)) echo "<option name=\"".$row['name']."\">".$row['name']."</option>\n"; ?> <table width="300" cellpadding="10" cellspacing="0" border="2"> <tr align="center" valign="top"> <td align="center" colspan="1" rowspan="1" bgcolor="#64b1ff"> <h3>Edit and Submit</h3> <form action="change_record.php" method="post"> <input type="Submit" value="Update"> </form> Click Here to acces that members File </td></tr></table> Quote Link to comment https://forums.phpfreaks.com/topic/64895-drop-down-select/#findComment-323830 Share on other sites More sharing options...
lemmin Posted August 23, 2007 Share Posted August 23, 2007 The <select> and <option> tags need to be inside the <form> tag. Also, "$_POST['name']" is a value and you aren't telling it what to do. Assuming you just want to print it out to test it, put an "echo " in front of it. Quote Link to comment https://forums.phpfreaks.com/topic/64895-drop-down-select/#findComment-332435 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.