Hi,
in database there is a one record stored that is
M-L-XL-XXL
i want to retrieve all these items 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
How to display value in combobox
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Code: Select all
//change `table` to your real table name
$result = mysql_query('SELECT * FROM `table`') or die(mysql_error());
//setup the drop down menu
//change input_name to whatever you want it to
echo '<select name="input_name">';
//fill drop down menu
while ($row = mysql_fetch_assoc($result)) {
echo '<option value="'.$row['column_name'].'">'.$row['column_name'].'</a>';
}
//close dropdown
echo '</select>';
Last edited by John Cartwright on Thu Sep 15, 2005 11:52 am, edited 1 time in total.
if the record is a string M-L-XL-XXL, to separate them:
then use the foreach loop to create the combobox
if the records M,L,XL,XXL, etc, are different columns than use what Jcart gave you.
Code: Select all
$values = explode('-',$record);Code: Select all
<?
echo "<select name='combobox'>";
foreach ($values as $k=>$v)
{
echo "<option value='$v'>$v</option>";
}
echo '</select>';
?>some problem in combobox
hi, . i have this string value
"M-L-XL-XXL"
which is stored in db
i want to fetch this record from db and display it in combobox.
i don't want to store this whole string in a combo box.
i want to seperately show each character with in a combox box
means my combo box show four values instead of one which are
M
L
XL
XXL
how can i do this
plz reply
"M-L-XL-XXL"
which is stored in db
i want to fetch this record from db and display it in combobox.
i don't want to store this whole string in a combo box.
i want to seperately show each character with in a combox box
means my combo box show four values instead of one which are
M
L
XL
XXL
how can i do this
plz reply
- harrisonad
- Forum Contributor
- Posts: 288
- Joined: Fri Oct 15, 2004 4:58 am
- Location: Philippines
- Contact: