dennismonsewicz Posted September 16, 2008 Share Posted September 16, 2008 I have the following html select echo '<select name="company">'; echo '<option value="" selected="selected">' . $results->company . '</option>'; echo '<option value="Health Resources">company1</option>'; echo '<option value="True Health">company2</option>'; echo '</select>'; The DB is going to house company 1 or company 2 depending upon the company selected at the time the user was creating this entry. Well I am wanting to make it where if company1 is in the DB then it doesn't repeat itself in the select list. And vice versa for company2. Any ideas? Link to comment https://forums.phpfreaks.com/topic/124530-solved-select-option-help/ Share on other sites More sharing options...
barrylee Posted September 16, 2008 Share Posted September 16, 2008 $sql = mysql_query("SELECT company FROM table") or die(mysql_error()); $row = mysql_fetch_assoc($sql); if($row['company']=="company 1") { $option = "<option name='company 2'>company 2</option>"; } else { $option = "<option name='company 1'>company 1</option>"; } $var = "<select name='company'>"; $var .= $option; $var .="</select>"; obviously this can be built on but I hope this gives you the general idea Link to comment https://forums.phpfreaks.com/topic/124530-solved-select-option-help/#findComment-643105 Share on other sites More sharing options...
dennismonsewicz Posted September 16, 2008 Author Share Posted September 16, 2008 thanks... I knew i could do that.. I was just wondering if there was any more dynamic way to solve this problem. Thanks though, problem solved Link to comment https://forums.phpfreaks.com/topic/124530-solved-select-option-help/#findComment-643123 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.