0

Hi , I am using an explode function to split some comma separated colors into a drop down list.

<?php

// Split the string up into an array of values
$dropdown_data = explode(",", $row_rsApparel['Item_Colors']);


// Output a dropdown
echo '<select name="color" id = "color">';
foreach($dropdown_data as $key => $value) {
  echo '<option value="'.$key.'">'.$value.'</option>';
}
echo '</select>';
?>

The drop down works perfectly but I can't seem to get that info into the cart. If I use a standard drop down list in dreamweaver, no problem binding that to the cart. Just not sure how to bind the selection from a php generated list into the cart?

any help would surely be appreciated.

thanks nigel

2
Contributors
4
Replies
6
Views
8 Years
Discussion Span
Last Post by nigelsponge
0

You use the $_POST array variable in your form handling routine to get the select value, namely $_POST in your case. Once you get this, simply use it in your update/insert SQL query.

0

Thanks so much ardav, I'm close, I am getting info into the cart from that drop down, but it is putting the number of the array into the cart instead of the color name (red,blue,etc.)

I'ver tried this but no luck:

"".((isset($_POST["Color2.$value"]))?$_POST["Color2.value"]:"")  ."";

I'm not sure how to get the actual color value in syntax wise. Kind of new to php.

0

This is because your the $_POST is picking up the array 'key' value and not the value displayed in the dropdown. Do this:

echo '<select name="color" id = "color">';
foreach($dropdown_data as $value) {
  echo '<option value="'.$value.'">'.$value.'</option>';
}
echo '</select>';

I think that should work.

0

This is because your the $_POST is picking up the array 'key' value and not the value displayed in the dropdown. Do this:

echo '<select name="color" id = "color">';
foreach($dropdown_data as $value) {
  echo '<option value="'.$value.'">'.$value.'</option>';
}
echo '</select>';

I think that should work.

Thanks so much ardav, I understand now. Appreciate your quick reply.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.