Seperate Sizes

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
leewad
Forum Commoner
Posts: 91
Joined: Tue May 11, 2004 8:32 am

Seperate Sizes

Post 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
rubberjohn
Forum Contributor
Posts: 193
Joined: Fri Feb 25, 2005 4:03 am

Post 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..."
leewad
Forum Commoner
Posts: 91
Joined: Tue May 11, 2004 8:32 am

Post by leewad »

Great stuff it worked, thank you
Post Reply