Re: combo box
| From: | Seung Hwan Kang | Date: | Tue, 02 Dec 2003 00:52:35 +0000 |
| Subject: | Re: combo box | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-171572@lists.php.net to get a copy of this message | ||
If I were you, I do this way.
// in your HTML form.
<select name="flag">
<option value="1"> Husband</option>
...
</select>
// DB
then insert 1, 2, 3, 4. //it will be one of them from flag variable.
// when you retrieve it...
if (flag == 1)
echo "Husband"
if ...
and so on. :)
Kang
Chan Hweefarn Saputra wrote:
hi :) i am creating a webpage. i use a combo box to let user choose which folder they want. after they choose, it will be saved into the database. the next time they load this page, it will retrieve the data from database and appear at the combo box. i already done that. but now the problem is....the data that i retrieve from the database will same with the options in the combo box. so, it will become 2 same options. i am afraid this will confuse the user. so i want to fix it. if u dont understand what i mean, try look at the picture & coding below: folder: husbandfriend family boss husband_______________________________________________________ this is the code: <select size="1" name="groupMailbox1"> <option><?php echo $row["groupMailbox1"]; ?></option> <?php//Open Directory you want to include //$base='/home/a/mail'; $handel = opendir($base); //Get contents of the directory while (false !== ($file = readdir($handel))) { if (is_dir($base . "/" . $file) && ($file !== ".") && ($file !== "..")) { list($filename, $ext) = explode(".", $file); list($main, $sub, $include) = explode("/", $PHP_SELF); echo "<option value=\"$file\""; //Echo the file name in a combo box if ($inc==$file) echo " selected"; echo">$file</option>\n"; echo $file; } } ?></select><p></p> ___________________________________________________________ how to make it so that the data that we retrieve from database, if same with the options we have, we only need to make that option selected? thanks :) hweefarn __________________________________ Do you Yahoo!? Free Pop-Up Blocker - Get it now http://companion.yahoo.com/