html - Take the name attribute of an option element and put it into a php variable -


Then I have an HTML dropdown that has been created in php. echo & lt; Select ID = "myselect" name = "myselect" & gt; '; While ($ line = mysql_fetch_array ($ query)) {echo '& lt; Option value = "'. $ Line [' categories']. '" Id = "'. $ Line ['categories']." & Gt; '. $ Line ['categories']' & lt; / Option & gt; '. } Echo '& lt; / Select & gt; ';

What I have to do, takes the chosen option and turns it into a variable, so I can pass it to another php page.

  echo & lt; Id = "myselect" name = "myselect" & gt; ; Echo '& lt; Option value = "make-selection" id = "make_selection" name = "make_selection" & gt; Choose your category & lt; / Option & gt; '; While ($ line = mysql_fetch_array ($ query)) {echo '& lt; Option value = "'. $ Line [' categories']. '" Id = "'. $ Line ['categories']." & Gt; '. $ Line ['categories']' & lt; / Option & gt; '. } Echo '& lt; / Select & gt; ';   

Above this:

  if ($ _ POST) {$ selection = $ _POST ['Message_section']; // $ do something with selection / possibly redirecting the user to the header ('location: page .php'); }    

Comments