title: mysql: wp database update
body: <p>So, I have a following js and php:</p>
  
  <p><strong>JS:</strong></p>
  
  <pre><code>var names = jQuery('#name').val();
  data : {'action':'AJAX' , name:names },
  </code></pre>
  
  <p>The <code>#name</code> values are <code>"mike,sean,steve"</code></p>
  
  <p><strong>PHP:</strong></p>
  
  <pre><code>global $wpdb;
  $names      = $_POST['name'];   
  $table      = $wpdb-&gt;prefix . 'my_name';    
  $RSS_UPDATE = $wpdb-&gt;get_col("SELECT update_number FROM $table WHERE id_name IN ($names)"); 
  
  //update_number are int (example: 0,3,1,2)
  
  $name  = explode(',', $names);
  if ( $RSS_UPDATE ){
      foreach ( $RSS_UPDATE as $RSS_SINGLE ){         
          $RSS_ROW_NEW  = $RSS_SINGLE + 1;            
          $wpdb-&gt;update($table, array('update_number' =&gt; $RSS_ROW_NEW),array( 'id_name' =&gt; $name));               
      }   
  }   
  </code></pre>
  
  <p>So, few things:</p>
  
  <p><strong>what I am trying to achieve:</strong></p>
  
  <p>With the input values, get corresponding <code>update_number</code>. Then increase each value by "1" and update the same column with the new value.</p>
  
  <p><strong>Errors</strong> </p>
  
  <ol>
  <li><p><code>Unknown column 'Array' in 'where clause' for query SELECT update_number FROM wp_my_name WHERE id_name IN (Array)</code></p></li>
  <li><p>Just in general, something is not right...</p></li>
  </ol>
  
  <p>Can someone help me out?</p>
  
  <p>Thank you.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Does this look right?</p>
  
  <pre><code>if(!empty($_POST['name'])) {    
      $names      = $_POST['name'];   //array
      $table      = $wpdb-&gt;prefix . 'rh_subs';
      $query      = "SELECT update_number FROM $table WHERE id_name = %s";    
      $RSS_UPDATE = $wpdb-&gt;get_results($wpdb-&gt;prepare($query, $names));
      if(!empty($RSS_UPDATE)) {
          foreach($RSS_UPDATE as $RSS_SINGLE) { // for each row
              $RSS_ROW_NEW  = $RSS_SINGLE-&gt;update_number + 1;
              $wpdb-&gt;update($table, array('update_number' =&gt; $RSS_ROW_NEW),array('id_name' =&gt; $RSS_SINGLE-&gt;id_name));
          }
      }
   }  
  </code></pre>