How to count the page visits using php PDO

  PHP

Email

How to visits Count  using php PDO

Create table first

and use this coding

$ip = $_SERVER['REMOTE_ADDR'];
                            $sql = "Select id From Counter WHERE ip='$ip'";
                            $fetch_cat=$con->prepare($sql);
                            $fetch_cat->execute();
                            $CheckIp=$fetch_cat->rowCount();
                            if($CheckIp==0)
                            {
                                $query ="insert into Counter(id,ip) VALUES('NULL','$ip') ";
                                $fetch_cat=$con->prepare($query);
                                $fetch_cat->execute();
                            }
                            $number=$con->prepare("select ip from Counter");
                            $number->execute();
                            $vis=$number->rowCount();
                             $vis
Spread the Code

Leave a Reply

avatar

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Subscribe  
Notify of