...

View Full Version : storing values in combo box



eshban
09-15-2005, 06:36 AM
HI,
in database there is a one record stored that is

M-L-XL-XXL

i want to retrieve this record from database and show it in combo box. MEans i want four values in combobox which are
M
L
XL
XXL


how can i seperate each value and implement it

plz reply
eshban

gunman
09-15-2005, 07:29 AM
After retrieve values in proper order you put this code:
<select name="name">
<option>Choose One</option>
<?for($i=0;$i<$br;$i++){?>
<option value="<?=$res[0]"><?echo $res[0];?></option>
<?}?>
</select>

where $br is count of fields in your table;
$res[] is result from retrieving data from table

Fou-Lu
09-15-2005, 09:52 AM
And with that you end up with $br options for the exact same thing.
I'm assuming that you know how to query here, and we will store the value result of 'M-L-XL-XXL' in variable $row:


/* $row = 'M-L-XL-XXL'; */
$row = explode('-', $row);
// Now we have an array:
if (!empty($row))
{
echo '<select name="selectname">';
for ($i = 0; $i < count($row); $i++)
{
echo '<option value="' . $row[$i] . '">' . $row[$i] . '</option>';
}
echo '</select>';
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum