Jump to content

Select from list to create drop down


xcandiottix

Recommended Posts

I want to check my database's "Category" row, then use that information to create a drop down of every category with in that row. I don't want to same category to appear twice tho. I think this could be a lengthy answer for anyone to give so does anyone know a good "how to" already on this subject?

 

<form action=""> 
<select name="category" onchange="showCategory(this.value)">
<option value="">Select a category:</option>
<?php
$con = mysql_connect(".com","UN","PW");
mysql_select_db("DB", $con);
$data = mysql_query("SELECT * FROM application_directory") or die(mysql_error());
while($info = mysql_fetch_array($data)){
echo '<option value="'.$info["db_Appcategory"].'">'.$info["db_Appcategory"].'</option>';
}
?>
</select>
</form>

 

I have this so far to test, and it works but obviously it will just create one item in the drop down. Any help is greatly appreciated =)

*edit- I've added the while loop so that way it will create a new item for each row

Link to comment
https://forums.phpfreaks.com/topic/208324-select-from-list-to-create-drop-down/
Share on other sites

$data = mysql_query("SELECT DISTINCT db_Appcategory FROM application_directory") or die(mysql_error());

Not sure what you're trying to ask, but the sql above will only echo unique db_Appcategorys, no multiples.

 

Thanks for understanding my mumbo jumbo... that's EXACTLY what I needed... thanks!

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.