<html> <head> <script type="text/javascript" src="select.js"> </script> </head> <body> <select id="secelctThis"> <option selected ="selected">Select a Destination</option> <option value="http://www.google.com">Google</option> <option value="http://www.facebook.com">Facebook</option> <option value="http://www.gmail.com">Gmail</option> </select> </body> </html> this is my code. I need to retrieve value field from the database. Can anyone tell me how to get data from Data Base in the drop down list.
In your PHP file (this is pseudocode - the exact code depends on your database and how you prefer getting data from it): <html> <head> <script type="text/javascript" src="select.js"> </script> </head> <body> <?php //code to get your data into a recordset ?> <select id="seelctThis"> <option selected ="selected">Select a Destination</option> <?php //while not end of the recordset echo '<option value='.recordset field 1.'>'.recordset field 2.'</option>'; ?> </select> </body> </html> PHP: