Page 1 of 1

Seperate Sizes

Posted: Sun Apr 09, 2006 12:37 pm
by leewad
Hi

I`m creating a website which pulls sizes of shoes via a database, the problem is that its stored as text like: 4,5,6,7,8,9,10 etc

How can I seperate the numbers and add them to a drop down and the code would be something like:

Code: Select all

<form method="POST" action="">
<select size="1" name="Size">
<option selected>Please Select Size</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
</select>
</form>
Thanks

Posted: Sun Apr 09, 2006 12:43 pm
by rubberjohn

Code: Select all

$arr_shoe = explode(",", $my_shoe_var);


$drop_down =  '<select name="Size" '; 
$drop_down .= '<option value="" selected="selected">Make a Selection</option>'; 

foreach( $arr_shoe as $value )
{
 
	$all_tags .= '<option value="' . $value . '">' . $value . '</option>'; 
 
}
$drop_down .=  '</select>';
**EDIT you dont need the "SELECTED>Choose a Shoe Size" after the select name declaration

where $my_shoe_var = "4,5,6,7,8,9,10..."

Posted: Sun Apr 09, 2006 1:01 pm
by leewad
Great stuff it worked, thank you