Hi a kind member (ardav) helped me with some php scripting to get a drop list to be populated using an exploded function in php. I need to also add a first option to the list that would say "Choose Color" as the client wants the light and dark colors separated. I need that first option "Choose Color" not to be passed to the cart as they can only choose either a light or dark color. My code so far below:

<?php

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


// Output a dropdown
echo '<select name="DarkColor" id ="DarkColor>';
foreach($dropdown_data as $value) {

  echo '<option value="'.$value.'">'.$value.'</option>';
}
echo '</select>';
?>

any help would truly be appreciated

<?php
$dropdown_data = explode(",", $row_rsAppare['Item_Dark_Colors']);
echo '<select name="DarkColor" id ="DarkColor>';
echo '<option selected="selected" value="">Choose Color</option>';
foreach($dropdown_data as $value) { 
echo '<option value="'.$value.'">'.$value.'</option>'; 
}
echo '</select>';
?>

Thanks so much, I had tried what you wrote but i put the

echo '<option selected="selected" value="">Choose Color</option>';

inside the

foreach() loop.

thanks again

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.