Use this code in your application:
<?
$query="SELECT sub_cat_id, sub_cat_name FROM category";
/* You can add order by clause to the sql statement if the names are to be displayed in alphabetical order */
$result = mysql_query ($query);
echo "<select name=category value=''></option>";
// printing the list box select command
while($nt=mysql_fetch_array($result)){//Array or records stored in $nt
echo "<option value=$nt[sub_cat_id]>$nt[sub_cat_name]</option>";
/* Option values are added by looping through the array */
}
echo "</select>";// Closing of list box
?>
Shanti C
Posting Virtuoso
1,642 posts since Jul 2008
Reputation Points: 137
Solved Threads: 162
Shanti C
Posting Virtuoso
1,642 posts since Jul 2008
Reputation Points: 137
Solved Threads: 162