How can I use php to control the selected values in the select statement?

Source: Internet
Author: User
How can I use php to control the selected values in the select statement? For example, I have a select form.
option_1option_2.....option_n

The last n may be very large. my design is to save the user form submitted to mysql, and then the user can edit it. on the editing page, this single-choice form must be displayed as a mysql value in the selected status. I have read the value in mysql $ value_select_1. how can I use php to control this select_1 form and select the value of $ value_select_1?

Soon after learning php, I hope I will not be enlightened.


Reply to discussion (solution)

The data in the database is to take the value 1 when the saved data is output, and then determine whether the value is equal when the foreach output, that is, selected.

The data in the database is to take the value 1 when the saved data is output, and then determine whether the value is equal when the foreach output, that is, selected.
The moderator gave me a remote Chin.
My environment is not working yet !!!!

The data in the database is to take the value 1 when the saved data is output, and then determine whether the value is equal when the foreach output, that is, selected.
Niu

$value_select_1=1;$select_arr=array('value_1','value_2','value_3','value_4');foreach ($select_arr as $value){    if(intval(substr($value,-1,1))==$value_select_1)        echo $value.' selected';}

$value_select_1=1;$select_arr=array('value_1','value_2','value_3','value_4');foreach ($select_arr as $value){    if(intval(substr($value,-1,1))==$value_select_1)        echo $value.' selected';}

Thanks to the moderator. why is it-1 to 1?


$value_select_1=1;$select_arr=array('value_1','value_2','value_3','value_4');foreach ($select_arr as $value){    if(intval(substr($value,-1,1))==$value_select_1)        echo $value.' selected';}

Thanks to the moderator. why is it-1 to 1?
If you understand, take the last one. thank you!

 '; Echo''; For ($ I = 1; $ I <= 10; $ I ++) {echo'Option _ '. $ I .'';} Echo''; $ Cur = 10; echo'

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.