overlordofevil Posted March 1, 2008 Share Posted March 1, 2008 Ok I am pulling info from a db and creating a drop down list. The drop down lists the name of the person. What I want to do is have this pull the id number as a hidden value and post the name and id to the next page. <html> <head><title></title></head> <body> <?php include("misc.inc"); //8 $conn = mysql_connect($msql_server, $msql_user, $msql_password) or die ("Unable to Connect"); mysql_select_db($msql_db, $conn) or die ("Unable to Connect to DB"); $query = "SELECT * FROM members"; $result = mysql_query($query) or die ("Couldn't execute query."); ?> <form action='addchar.php' method='POST'> <table border="0"> <tr> <td align="right"> <b>Players Name:</b> </td> <td> <?php echo "<select name='Players Name'>\n"; while ($row = mysql_fetch_array($result)) { extract($row); echo "<option value='$id $firstname $lastname'>$firstname $lastname\n"; } echo "</select>\n"; ?> </td> </tr> <tr> <td align="right"> <p> <input type="hidden" name="id" value="$id"> <input type="submit" value="ADD"> <input type="reset" value="RESET"> </td> </tr> </table> </form> </body> </html> The problem I am having is the name and id will not post I am not sure how to pull the data or what code will pull it for me. Any assistance would be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/93788-tryign-to-post-data-from-a-selection-list/ Share on other sites More sharing options...
sKunKbad Posted March 1, 2008 Share Posted March 1, 2008 You might need to close your option: <option value="Name">Name</option> Quote Link to comment https://forums.phpfreaks.com/topic/93788-tryign-to-post-data-from-a-selection-list/#findComment-480581 Share on other sites More sharing options...
overlordofevil Posted March 1, 2008 Author Share Posted March 1, 2008 I tried that and the issue I am having is when the variables come in from the DB request I can get them to the next page but what I want to do is get the id number to transfer over. I have tried to combine the first and last name and send it just as name and that works. But when I try to use split so I can get the original value back (this is so I can pull info from the db again) it just won't work. any help on figuring out how to get the id to transfer over would help out. Quote Link to comment https://forums.phpfreaks.com/topic/93788-tryign-to-post-data-from-a-selection-list/#findComment-480585 Share on other sites More sharing options...
IT-Guy Posted March 1, 2008 Share Posted March 1, 2008 Have you tried storing the data in a session, then calling it on the next page? Im not an expert, but I made a login a while back and I needed the data to not only go to the next page, but to go to three other pages, and I just stored it in a session, and called it when I needed it. Cookies might help too, but read up on it. Ill try and see if I can look up something regarding your problem I read a while back, Ill post here if I find it Quote Link to comment https://forums.phpfreaks.com/topic/93788-tryign-to-post-data-from-a-selection-list/#findComment-480586 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.