tags:

views:

72

answers:

2

i have one doubt.I already stored some data in database.my constraints is how to list out all the data inside drop down list box using html.

I am using servlet.the form designs using Html.MY constraints is if i run the html form the form designed displayed

It contained one dropdownlist. My constraints is i want to diaplay all the records in the dropdown list.My servlet program do action based on the selction of drop down list.

A: 

If you have php , you can following this things.

Using PHP could achieve this one.

require 'DB.php' ;
$db = DB::connect("argument"); // Connect the data base 
print '<select name="option" >';
$q = $db->query( "SELECT * FROM dishes ");  // execute the require query  
while ($row = $q->fetchRow()) {  // Fetch each row valeus. 
{
print " <option> " ;
print $row[0];        // put into select option 
print "</option>" ;
}
print "</select> ";
pavun_cool
A: 

Your question is very vague and unclear. However, here are the steps you would need to do. You should be able to search for how to do each of these if you're not sure. All this is done in server-side code.

  1. Connect to the database.
  2. Fetch the data from the database, usually as an array of rows.
  3. Output the start of the dropdown: <select name="records">
  4. Loop through each element in the array. For each one, output the element: <option>NAME</option>
  5. Close the drop down tag: </select>
DisgruntledGoat