How to set the default items in <select> </select> in php

Source: Internet
Author: User
How to Set & lt; select & gt; & lt;/select & gt; in php to read relevant data from the database and bind it to & lt; select & gt; & lt; /select & gt; Mark, how to bind the values in the database to the first item of & lt; select & gt; & lt;/select & gt; by default, for example, the database column is male, & lt; select & gt; how to set in php Default items in
Read related data from the database and bind it Tag, how to bind the values in the database For example, if the database column is male, Is male by default

------ Solution --------------------
Add selected = selected

For example:

Male
------ Solution --------------------
First, the basic usage is Male;
If you want to query a database and it becomes a default item, you have to write a query statement, first query it, and then nest it into the php output. for example ::

Hope to help the landlord.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.