Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- how can i show the number of visitors [closed]
- <form action='' method='post'/>
- <table dir='rtl' width='100%' cellpadding='0' cellspacing='0'>
- <tr>
- <td valign='top' width='75%' >
- <?php
- $getidtopic=$_GET['id_topic'];
- $shownews=mysql_query("select * from topics where id_topic='$getidtopic'");
- $row=mysql_fetch_object($shownews);
- echo "<div id='title'>$row->topic_title</div>";
- ;?>
- <?php
- if ($_REQUEST['full']=='news'){
- $getidtopic=$_GET['id_topic'];
- $shownews=mysql_query("select * from topics where id_topic='$getidtopic'");
- $show_section_in_topic=mysql_query("
- select sections.sec_name,sections.id_sec ,topics.topic_title from sections,topics where sections.id_sec=topics.topic_sec
- and topics.id_topic='$getidtopic'
- ")or die (mysql_error());
- while ($sec_name1=mysql_fetch_object($show_section_in_topic)){
- $section_id=$sec_name1->id_sec;
- $section_name=$sec_name1->sec_name;
- $sec_in_topic="<a href='display_sec.php?id_sec=$section_id'>$section_name</a>";
- }
- $row=mysql_fetch_object($shownews);
- echo "<br/>";
- echo "<div id='news'>
- <span style='color:red'> published :</span> $row->date  
- <span style='color:red'>section :</span> $sec_in_topic
- <br/>
- <br/>
- $row->topic
- <a href='index.php'><span style='color:red'>back -> </span></a>
- </div>
- ";
- mysql_free_result($shownews);
- }
- ?>
- <?php
- $local='localhost';
- $user='root';
- $pass='root';
- $database='a_database';
- mysql_connect($local,$user,$pass);
- mysql_select_db($database);
- $user_ip=$_SERVER['REMOTE_ADDR'];
- function ip_exists($ip){
- global $user_ip;
- $query="select `ip` from `hits_ip` where `ip`='$user_ip'";
- $query_run=mysql_query($query);
- $mysql_num_rows=mysql_num_rows($query_run);
- if ($mysql_num_rows==0){
- return false;
- }else if ($mysql_num_rows>=1){
- return true;
- }
- }
- function ip_add ($ip){
- $query="insert into `hits_ip` values('$ip')";
- $query_run=mysql_query($query);
- }
- function update_count(){
- $query="select `count` from `hits_count`";
- if ($query_run=mysql_query($query)){
- $count=mysql_result($query_run,0,'count');
- $count_inc=$count+1;
- $query_update="update `hits_count` set count='$count_inc'";
- $mysql_update_run=mysql_query($query_update);
- }
- }
- if (!ip_exists($user_ip)){
- update_count();
- ip_add($user_ip);
- }
- $count_field="select `count` from `hits_count`";
- $run_count_field=mysql_query($count_field)or die (mysql_error());
- echo $num_f=mysql_num_rows($run_count_field);
- ?>
- <?php
- $local='localhost';
- $user='root';
- $pass='root';
- $database='a_database';
- mysql_connect($local,$user,$pass);
- mysql_select_db($database);
- $user_ip=$_SERVER['REMOTE_ADDR'];
- function ip_exists($ip){
- global $user_ip;
- $query="select `ip` from `hits_ip` where `ip`='$user_ip'";
- $query_run=mysql_query($query);
- $mysql_num_rows=mysql_num_rows($query_run);
- if ($mysql_num_rows==0){
- return false;
- }else if ($mysql_num_rows>=1){
- return true;
- }
- }
- function ip_add ($ip){
- $query="insert into `hits_ip` values('$ip')";
- $query_run=mysql_query($query);
- }
- function update_count(){
- $query="select `count` from `hits_count`";
- if ($query_run=mysql_query($query)){
- $count=mysql_result($query_run,0,'count');
- $count_inc=$count+1;
- $query_update="update `hits_count` set count='$count_inc'";
- $mysql_update_run=mysql_query($query_update);
- }
- }
- if (!ip_exists($user_ip)){
- update_count();
- ip_add($user_ip);
- }
- $count_field="select `count` from `hits_count`";
- $run_count_field=mysql_query($count_field)or die (mysql_error());
- echo $num_f=mysql_num_rows($run_count_field);
- ?>
Add Comment
Please, Sign In to add comment