Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.