Re: How to do a "case" like loop with an array?

From: Date: Mon, 11 Sep 2000 02:36:05 +0000
Subject: Re: How to do a "case" like loop with an array?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-16109@lists.php.net to get a copy of this message
<select name="foo"> <? /* your php loop, whatever */ echo "<option value=\"$your_val\"". $foo == $your_val ? " selected" : "". ">Some Text</option>"; ?> </select> ----- Original Message ----- From: "Shane McBride" <php@riversidedesigns.net> To: "Php-General" <php-general@lists.php.net> Sent: Monday, September 11, 2000 12:30 PM Subject: [PHP] How to do a "case" like loop with an array? I have database table that is called categories. The table holds the variable names for <option>'s in a <select> list. I did this so if I added a new category, it would not require any code change to create the code list. It really words GREAT. Here's the problem: If I want to modify a product (from another table), I had the php file hardcoded with the categories, and used a case statement to automatically display the correct <option>, and then continue filling in the other <option> underneath. Now that I have this new "dynamic" way of populating the <select> list, I am baffled when it comes to creating the list dynamically while having the correct <option> to be selected..... Any ideas????? Thanks SO Much!!! Shane

« previous php.general (#16109) next »