how to increase the counter by one

I do not understand what is wrong with me, I believe that the request to the correct database. I am trying to increase the counter by one views, while post_id and hosts simply rewritten or left unchanged

when the user selects a specific post views counter shall be increased by one, and another counter hosts remain unchanged.

$current_ip = $wpdb->get_row( $wpdb->prepare("select * from ".$wpdb->prefix."views_date where ip_address='$ip'"));

if($current_ip == '1') {

  $wpdb->update($wpdb->prefix."views_count",
    array(              
      'post_id' =>$id,
      'hosts'=>'hosts', 
      'views'=>'views'+1 //not increased by one
    )
  );

}


"post_id INT(11) NOT NULL, hosts INT(11) NOT NULL, views INT(11) NOT NULL"

Answers


Try this: 'views'=> views+1


This is likely failing because if($current_ip == '1') will not be equal to 1.

$current_ip is the results of the complete row of data from the database, so you need to get the data from the IP column, something like:

while($row = $current_ip->fetch_assoc()){ 
    $ip_value_from_database = $row["ip_address"];
}

if($ip_value_from_database == '1') {
    //update query
}

Need Your Help

How to determine iPhone/iPad target and iOS version while submission to AppStore?

iphone ios6 ios7 app-store appstore-approval

I am uploading my App into AppStore. My app is displayed fine on iPhone, not on iPad. In addition, my App just works on iOS 6 or higher.