php - Pass array values into select option fields within a form? -


This is based in PHP.

Is it possible to take an array like this: $ SELECT_INDUSTRY = array ("medicine" => gt; "attribute", "medical" => Specialty "," hair disease "=>" specialty ");

And pass those two values ​​in something like this:

  & lt; Select & gt; & Lt; Option value = "$ SELECT_INDUSTRY []" & gt; $ SELECT_INDUSTRY [] & lt; / Options & gt; & Lt; / Select & gt;   

Where the medical value is being given, and the special public must face.

This is the function I use for the actual selection box:

  $ SELECT_INDUSTRY = array ("medical", "medical", "hair disease"); $ FORM_SELECT_SIZE = 'Input-min'; Function get_options_industry ($ arr = array ()) {global $ FORM_SELECT_SIZE; = "Industry" & gt; Industry & lt; / Label & gt; & Lt; Div class = "controls" & gt; & Lt; Echo to select name & lt; Div class = "control-group" & gt; Label class = "control-label" = "industry" id = "industry" category = "'. $ FORM_SELECT_SIZE." "Gt; & lt; Option value = & gt; Select an industry & lt; / option & gt; 'foreign currency (as the $ AR $ option) {echo' option & gt; $ Option. '& Lt; / option & gt;';} echo '& lt; / select & gt; & lt; / div & gt; & lt; / div & gt;' ;; $ $ FORM_FIELD_INDUSTRY = $ SELECT_INDUSTRY ;   

And I am selecting this type of:

  & lt ;? php get_options_industry ($ FORM_FIELD_INDUSTRY)? & Gt;   

I think I am near, or at least on the right path, I can not figure out how to drag the first ARA value in the value field, then the second real name.

The goal is to get the value given in the form, it is different from the public face name I know that the above Aray definition which I have given can not be the right way to do this.

Solution

Thanks for some responses below Here is the last answer to my problem solving:

  $ SELECT_INDUSTRY = array ("medicine" => gt; "medical", "medical" =>, "medical", "hair Disease "= & gt;" medical "); $ FORM_SELECT_SIZE = 'input-min'; function get_options_industry ($ arr = array); {global $ FORM_SELECT_SIZE; = "Industry" & gt; Industry & lt; / Label & gt; & Lt; Div class = "controls" & gt; & Lt; Echo to select name & lt; Div class = "control-group" & gt; Label class = "control-label" = "industry" id = "industry" category = "'. $ FORM_SELECT_SIZE." "Gt; & lt; Option value = & gt; Select an industry & lt; / option & gt; 'foreign currency ($ AR $ key = & gt; $ value) {echo' & lt; option value = '' . $ Value. "& Gt; '. $ Key.' & Lt; / option & gt; 'echo' & lt; / select & gt; & lt; / div & gt; & lt; / div & gt; ';;; $ FORM_FIELD_INDUSTRY = $ SELECT_INDUSTRY;   

I have to make sure that my key is unique, so no duplicate will be erased.

, "attribute", "hair Disease "= & Gt;" attribute "); .... other stuff you already have .... foreach ($ arr $ val => $ option) {echo '& lt; option value =' ' . $ Val '' & Gt; '. $ Option.' & Lt; / option & gt; ';}

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -