<select name="select">
</select>
I want to populate the above tag with values from database.
I have written PHP code up to this.
while($row=mysql_fetch_array($result))
{
}
$row is fetching correct values. How to add it to the <select>
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
What about something like this :
Of course, up to you to decide which items from
$rowshould be used for the value and the text of each<option>Just make sure you are escaping the data that comes from your DB — especially if it can contain HTML ; as you are outputting HTML, this can be done with [`htmlspecialchars`][1] or [`htmlentities`][2].
Note that those might take a couple of additionnal parameters that I didn’t use in my example — setting those can be useful, depending on the charset you’re using.