php - Dropdown select based on database entries -


Therefore, I want to automatically populate the "yes" selection of the dropdown, or alternatively, "no" Would like to select The dropdown which will be used to evaluate the returned value from the database query will be selected.

I have thought that since it is a real / incorrect auto-population to write only two conditions, but I thought the way to write code is better (read: less messy code) Depending on the result, auto-populate the correct selection from the drop down.

The code base I am trying to write will check the variables against all the selections, then by adding a string that will select the drop down to see the user.

My question is that this would be an easy way to do this, instead of

  $ this-> Db- & gt; Select (select 'row')  

Code Inquiry Code written by PHP in code for every possible drop down value:); $ Result = $ this- & gt; Db- & gt; Obtain ('Table'); // It just selects the values ​​and returns this code works, I'm just looking for a better way to do this job so that someone knows, because I'm going to drop down with hundreds of possibilities , Of which, I should select a predefined one. // $ result-> Line = "yes" if ($ result = "yes") # # "Yes" selected with code # to resonate the radio button) and # {# click on the radio button with the code "selected}"

have you checked in the CI? You can use the form_radio And you can provide the value you want to select in the third parameter:

  form_radio ('field_name', 'yes', $ result ==' yes'); form_radio ('field_name ',' No ', $ result ==' no ');  

The first parameter f The name of the field is, the second parameter is the value for the field, and the third parameter is the bullion (TRUE: radio selected, incorrect: not selected) Since it is a radio, the field must also be named.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -