Jump to content

[SOLVED] Combo Box


Mewsta

Recommended Posts

Do you have any code written? If you give us some code we can give you a specific solution to how you should/can do things. The best we can do right is form you a concept and some pseudo code.

 

I'm thinking that you can get all the data from the database into an array. From there, use the array_unique function to get rid of any duplicates. From there, you can run a loop (based on the number of results; using count or something of the like) that will create the HTML needed to form the combo box you want.

Link to comment
https://forums.phpfreaks.com/topic/40231-solved-combo-box/#findComment-194640
Share on other sites

<select name=mycomboname>
<?php
$combo = "SELECT DISTINCT(name_field) AS name, id FROM tablename";
$res = mysql_query($combo) or die(mysql_error());
while($r = mysql_fetch_assoc($res)){
  echo "<option value=\"".$r['id']."\">".$r['name']."</option>\n";
}
?>
</select>

 

Substitute the field names and the value of each option to fit your needs

 

Ray

Link to comment
https://forums.phpfreaks.com/topic/40231-solved-combo-box/#findComment-194673
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.