I want to count the number that how many people visited my post.My code is following:
function post_viewnum(){
global $wpdb;
$postid=$post->ID;
$postviewnum=$wpdb->get_var("SELECT viewnum FROM wp_posts WHERE ID='$postid'");
$postviewnum=$postviewnum+1;
$wpdb->query("UPDATE wp_posts SET viewnum='{$postviewnum}' Where ID='$postid'");
echo $postviewnum;
}
The trouble is i can't get the viewnum,and can't update its datebase.
↧
webviewer on "How to update datebase?"
↧