checkbox - PHP remeber checked checkboxes -


I am trying to put a filter using checkboxes. The problem occurs when I select some boxes and deposit values, all the boxes are selected again. I think the problem can be here

  if (isset ($ _ POST ['option_meno']))  

What could be the problem? And yes, I am new here, so to help simplify my code, it will also help me warm any thoughts

Thank you.

  & lt ;? Php // Create a MySQL connection $ query_o_meno = "Select from the menu via the command menu"; $ Result_meno = mysql_query ($ query_o_meno) or die (mysql_error ()); ? & Gt; & Lt; Form method = "post" & gt; & Lt ;? Php if (isset ($ _ POST ['Filtrovat'])) {// check check box "Lieutenant; Strong & gt; Menu: & lt; / strong & gt; Echo" & lt; Br / & gt; "; while ($ line = mysql_fetch_array ($ result_meno)) {// I believe the problem is the line given below ------------------- ---------- If (isset ($ _ POST ['option_meno'])) {echo "& lt; Input type = 'checkbox' name = 'option_meno []' value = '". $ Line [' menu ']."' Check / & gt; ". $ Line ['meno']; echo" & lt; Br / & gt; "; //}} and {echo" & lt; Input type = 'checkbox' name = 'option_meno []' value = '". $ Line [' menu ']."' / / Gt; ". $ Line ['meno']; echo" & lt; Br /> ";}}} and {$ option_meno = array (); echo" & lt; Strong & gt; Menu: & lt; / Strong> "; echo" & lt; Br / & gt; "; while ($ row = mysql_fetch_array ($ result_meno)) {echo" & lt; Input type = 'checkbox' name = 'option_meno []' value = '". $ Line [' menu ']."' Check / & gt; ". $ Line ['meno']; echo" & lt; Br> & gt; "$ option_meno [] = $ line ['menu'];}}? & Gt; Input type =" submit "name =" Filtrovat "value =" Filtrovat "/> & Lt; / form & gt;  

This is not a test, but should work :

  if (isset ($ _ POST ['Filtrovat'])) {// check check box "and lieutenant; Strong & gt; Menu: & lt; / Strong> Echo "
"; While ($ line = mysql_fetch_array ($ result_meno)) {$ checked = ""; If (isset ($ _ POST ['option_meno']) $ checked = in_array ($ line ['menu'], $ _ POST ['option_meno'])? "Check = 'check'": ""; echo "'$ Check / & gt;"; $ line [' meno ']; echo "
"}}

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -