I'm trying to allow users to select multiple items and post the selected items to the next page using PHP.
The process above works fine but the problem that I have right now is each item has a dropdown menu with some colours in it. the colours are the same.
what I need to do is to allow the users to select 1 colour for each selected item and send it to the next page.
This should be simple but for some reason all i get in the next page is "Array" instead of the value of selected option!
This is my code:
First page:
$products_list .= '<div align="center" style="width:150px; height:100px; float:left; border:solid 1px #666; margin-left:20px; margin-bottom:10px;">
<input style="float:left;" type="checkbox" name="check_list[]" value="'.$id.'" />
<img width="67" src="../inventory_images/'.$id.'.jpg" /><br />
'.$product_name.'<br />
<select name="colours[]">
<option >Choose a Colour</option>
<option value="Black">Black</option>
<option value="White">White</option>
<option value="Red">Red</option>
<option value="Blue">Blue</option>
</select>
</div>';
echo $products_list;
and on the second page i have this:
if(isset($_POST['submit'])){//to run PHP script on submit
if(!empty($_POST['check_list'])){
// Loop to store and display values of individual checked checkbox.
$products_list = "";
foreach($_POST['check_list'] as $selected){
$colours = $_POST['colours'];
//MYSQL QUERIES ETC GOES HERE....
$products_list .= ''.$product_name.' and '.$colours.'';
}
echo $products_list ;
on the second page the $product_name
for all the selected items gets echo-ed properly and correctly but the $colours
show Array.
could someone please advise on this ?
Thanks
EDIT:
Please note that $_POST['colours'];
is returning Array on the second page.