title: Updating the wordpress Custom table
body: <p>I am building a dashboard with custom User Data. Each element on the dashboard goes into the loop and shows the related information regarding that user.I am able to show the the custom field using session and loops but i need to update the information as well, somehow it is not updating. Please help with this:</p>
  
  <pre><code>&lt;?php 
  global $wpdb;
  $table_name = $wpdb-&gt;prefix . 'contract';
  $wsid = $_SESSION['wedding-values'];
  $results = $wpdb-&gt;get_results( "SELECT * FROM $table_name WHERE id=$wsid " );
  if ( $results ) {
      foreach ( $results as $result ){
          $wcname=$result-&gt;cname;
           $wctname=$result-&gt;ctname;
            $waddress=$result-&gt;address;
             $wmobile=$result-&gt;mobile;
              $wemail=$result-&gt;email;
               $wdate=$result-&gt;Date;
               $id=$result-&gt;id;
  
      }
  
  }
  if ( isset( $_POST['submit'] ) ){
  
   $wpdb-&gt;update($table_name,array(
      'cname'=&gt;$_POST['cname'],array('id'=&gt;$wsid))
  
         );
  
  }
  
   ?&gt;
  </code></pre>
  
  <p>Html:</p>
  
  <pre><code>&lt;div id="col-md-9"&gt;
      &lt;form action="" method="post"&gt;
      &lt;table&gt;    
      &lt;tr&gt;
          &lt;td&gt;&lt;p style="color: red"&gt; Couple Name &lt;/p&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type=text name=cname placeholder=&lt;?php echo $wcname;?&gt;&gt;&lt;/td&gt;
  
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;p style="color: red"&gt; Contact Name &lt;/p&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $wctname;?&gt;&lt;/td&gt;
  
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;p style="color: red"&gt; Address &lt;/p&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $waddress;?&gt;&lt;/td&gt;
  
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;p style="color: red"&gt; Mobile &lt;/p&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $wmobile;?&gt;&lt;/td&gt;
  
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;p style="color: red"&gt; Email&lt;/p&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $wemail;?&gt;&lt;/td&gt;
  
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;p style="color: red"&gt; Date Submitted&lt;/p&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $wdate;?&gt;&lt;/td&gt;
  
      &lt;/tr&gt;
      &lt;tr&gt;
  
          &lt;td&gt;&lt;input type="submit" name="editsave"  value="Edit and Save" &gt;&lt;/td&gt;
  
      &lt;/tr&gt;
  
    &lt;/table&gt;
    &lt;/form&gt;
      &lt;/div&gt;  
  </code></pre>