Giddy Rob Posted February 9, 2007 Share Posted February 9, 2007 Hey, I have a list that can have multiple selections and it is populated by running a mysql_fetch_array. <select name="alsolike" size="5" multiple> <?php include('dbconnect.php'); $likealso="SELECT productid, title FROM bknproducts"; $alsolike=mysql_query($likealso); while($alsolikerow = mysql_fetch_array($alsolike, MYSQL_NUM)){ echo"$alsolikerow[0]"; echo"<option value=\"$alsolikerow[0]\">$alsolikerow[0]: $alsolikerow[1]</option>"; } ?> </select> This part works fine but I am not sure how to get the mulitple values selected by the user back into a variable, which I will use to put the data back into the database. How do i know which options they have selected so i can just use the values of those in my concatenated variable? HELP ME PLEASE!!!! Cheers Rob Quote Link to comment https://forums.phpfreaks.com/topic/37781-multiple-lists-using-php/ Share on other sites More sharing options...
Jessica Posted February 9, 2007 Share Posted February 9, 2007 Make the name alsolike[] - this will $_POST an array of the values selected. Quote Link to comment https://forums.phpfreaks.com/topic/37781-multiple-lists-using-php/#findComment-180702 Share on other sites More sharing options...
Giddy Rob Posted February 9, 2007 Author Share Posted February 9, 2007 Hey, thanks for your help but I have never done that before. What would the code look like just to help me understand. Been working 13 hour days this week trying to get this project done so my brain ain't firing on all cylinders! Cheers Rob Quote Link to comment https://forums.phpfreaks.com/topic/37781-multiple-lists-using-php/#findComment-180713 Share on other sites More sharing options...
Jessica Posted February 9, 2007 Share Posted February 9, 2007 $arr = $_POST['alsolike']; print_r($arr); Quote Link to comment https://forums.phpfreaks.com/topic/37781-multiple-lists-using-php/#findComment-180714 Share on other sites More sharing options...
Giddy Rob Posted February 9, 2007 Author Share Posted February 9, 2007 Cheers for the quick response, i understand the post part. How do i define array in the first place for the menu? Quote Link to comment https://forums.phpfreaks.com/topic/37781-multiple-lists-using-php/#findComment-180723 Share on other sites More sharing options...
Jessica Posted February 9, 2007 Share Posted February 9, 2007 Make the name alsolike[] - this will $_POST an array of the values selected. Quote Link to comment https://forums.phpfreaks.com/topic/37781-multiple-lists-using-php/#findComment-180724 Share on other sites More sharing options...
Giddy Rob Posted February 9, 2007 Author Share Posted February 9, 2007 Sorry if this sounds dumb but u just mean: <select name="alsolike[]" size="5" multiple> cheers Rob Quote Link to comment https://forums.phpfreaks.com/topic/37781-multiple-lists-using-php/#findComment-180734 Share on other sites More sharing options...
Jessica Posted February 9, 2007 Share Posted February 9, 2007 Yes... Quote Link to comment https://forums.phpfreaks.com/topic/37781-multiple-lists-using-php/#findComment-180739 Share on other sites More sharing options...
Giddy Rob Posted February 9, 2007 Author Share Posted February 9, 2007 Wicked, that would have taken me ages to find the documentation on how to do that. Thanks a lot for your help Rob Quote Link to comment https://forums.phpfreaks.com/topic/37781-multiple-lists-using-php/#findComment-180752 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.