How to update datebase? (1 post)

  1. webviewer
    Posted 3 years ago #

    I want to count the number that how many people visited my post.My code is following:
    function post_viewnum(){
    global $wpdb;
    $postviewnum=$wpdb->get_var("SELECT viewnum FROM wp_posts WHERE ID='$postid'");
    $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.

Topic Closed

This topic has been closed to new replies.

About this Topic