title: WordPress plugin with database (mysql) query
body: <p>I am trying to create a plugin and I met a little problem. </p>
  
  <p>The plugin contains a simple admin page with checkboxes to perform functions. 
  So I created a function that creates a new table when installing the plugin. 
  The table contains 3 columns (ID, field, state):</p>
  
  <pre><code>global $wpdb;
  $mnzwpc_table_prefix=$wpdb-&gt;prefix.'mnzwpc_';
  define('MNZWPC_TABLE_PREFIX', $mnzwpc_table_prefix);
  
  function mnzwpc_install() {
      global $wpdb;
      $table = MNZWPC_TABLE_PREFIX."settings";
      $structure = "CREATE TABLE $table (
          id INT(9) NOT NULL AUTO_INCREMENT,
          field VARCHAR(50) NOT NULL,
          state VARCHAR(50) NOT NULL,
          UNIQUE KEY id (id)
      )";
      $wpdb-&gt;query($structure);
  
      $wpdb-&gt;query("INSERT INTO $table(field,state)
          VALUES('setting','')
      ");
  }
  </code></pre>
  
  <p>No problems here, the table is created when I install the plugin and removed when I uninstall. </p>
  
  <p>My problem comes from my input". </p>
  
  <p>I can not change the options in my table when a checkbox is checked and you click "Send". </p>
  
  <p>Currently, I use this variables i created:</p>
  
  <pre><code>$my_setting = 'setting'; // Set the field name 
  
  $hidden_field_name = 'submit_hidden'; // Save my input hidden in a var
  $data_field_name = 'setting'; // Set the field name in DB
  
  // If we click on "Save Changes", add the datas to my db
  if ( isset( $_POST[ $hidden_field_name ] ) &amp;&amp; $_POST[ $hidden_field_name ] == 'Y' ) {
      $opt_val = $_POST[ $data_field_name ];
  
      update_option( $my_setting, $opt_val );
  
  ?&gt; &lt;p&gt;&lt;strong&gt;Changes Saved.&lt;/strong&gt;&lt;/p&gt;
  &lt;?php } // End if ?&gt;
  </code></pre>
  
  <p>And this is my admin page:</p>
  
  <pre><code>    &lt;form action="" method="post"&gt;
          &lt;input type="hidden" name="&lt;?php echo $hidden_field_name; ?&gt;" value="Y"&gt;
  
          &lt;label for="&lt;?php echo $data_field_name; ?&gt;"&gt;Setting name&lt;/label&gt;
          &lt;input id="&lt;?php echo $data_field_name; ?&gt;" type="checkbox" name="&lt;?php echo $data_field_name; ?&gt;" value="&lt;?php echo $opt_val; ?&gt;" /&gt;
  
          &lt;hr /&gt;
  
          &lt;p class="submit"&gt;
              &lt;input type="submit" name="Submit" class="button-primary" value="&lt;?php esc_attr_e('Save Changes') ?&gt;" /&gt;
          &lt;/p&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>Of course, in my plugin code, I check the options and do the desired stuff:</p>
  
  <pre><code>function do_the_job() {
  
      // Variables for the field and option names
      $my_setting = 'setting';
  
      // Read in existing option value from database
      $opt_val = get_option( $my_setting );
  
      if ($opt_val != '1') {
          // Do something
      }
  }
  </code></pre>
  
  <p>In my plugin admin page, if I check a checkbox and then I click on "Save Changes", the settings are not saved on the database and the checkbox appears unchecked. But the admin page is refreshed and my message appears: Changes Saved.</p>
  
  <p>Any idea? I can upload my plugin on Github if you need the full code :/</p>