Guest User

Untitled

a guest
Jan 13th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.66 KB | None | 0 0
  1. how can i show the number of visitors [closed]
  2. <form action='' method='post'/>
  3. <table dir='rtl' width='100%' cellpadding='0' cellspacing='0'>
  4. <tr>
  5.  
  6. <td valign='top' width='75%' >
  7.  
  8. <?php
  9. $getidtopic=$_GET['id_topic'];
  10. $shownews=mysql_query("select * from topics where id_topic='$getidtopic'");
  11. $row=mysql_fetch_object($shownews);
  12. echo "<div id='title'>$row->topic_title</div>";
  13.  
  14. ;?>
  15.  
  16.  
  17. <?php
  18. if ($_REQUEST['full']=='news'){
  19. $getidtopic=$_GET['id_topic'];
  20. $shownews=mysql_query("select * from topics where id_topic='$getidtopic'");
  21. $show_section_in_topic=mysql_query("
  22. select sections.sec_name,sections.id_sec ,topics.topic_title from sections,topics where sections.id_sec=topics.topic_sec
  23. and topics.id_topic='$getidtopic'
  24. ")or die (mysql_error());
  25.  
  26. while ($sec_name1=mysql_fetch_object($show_section_in_topic)){
  27. $section_id=$sec_name1->id_sec;
  28. $section_name=$sec_name1->sec_name;
  29. $sec_in_topic="<a href='display_sec.php?id_sec=$section_id'>$section_name</a>";
  30. }
  31.  
  32.  
  33. $row=mysql_fetch_object($shownews);
  34. echo "<br/>";
  35. echo "<div id='news'>
  36. <span style='color:red'> published :</span> $row->date &nbsp
  37. <span style='color:red'>section :</span> $sec_in_topic
  38.  
  39.  
  40.  
  41. <br/>
  42. <br/>
  43.  
  44.  
  45.  
  46.  
  47. $row->topic
  48. <a href='index.php'><span style='color:red'>back -> </span></a>
  49.  
  50. </div>
  51.  
  52. ";
  53.  
  54. mysql_free_result($shownews);
  55.  
  56.  
  57. }
  58.  
  59.  
  60. ?>
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72. <?php
  73.  
  74. $local='localhost';
  75. $user='root';
  76. $pass='root';
  77. $database='a_database';
  78.  
  79. mysql_connect($local,$user,$pass);
  80. mysql_select_db($database);
  81.  
  82. $user_ip=$_SERVER['REMOTE_ADDR'];
  83.  
  84.  
  85.  
  86. function ip_exists($ip){
  87. global $user_ip;
  88. $query="select `ip` from `hits_ip` where `ip`='$user_ip'";
  89. $query_run=mysql_query($query);
  90. $mysql_num_rows=mysql_num_rows($query_run);
  91. if ($mysql_num_rows==0){
  92. return false;
  93. }else if ($mysql_num_rows>=1){
  94. return true;
  95. }
  96. }
  97.  
  98.  
  99. function ip_add ($ip){
  100. $query="insert into `hits_ip` values('$ip')";
  101. $query_run=mysql_query($query);
  102. }
  103.  
  104.  
  105.  
  106.  
  107. function update_count(){
  108. $query="select `count` from `hits_count`";
  109. if ($query_run=mysql_query($query)){
  110. $count=mysql_result($query_run,0,'count');
  111. $count_inc=$count+1;
  112. $query_update="update `hits_count` set count='$count_inc'";
  113. $mysql_update_run=mysql_query($query_update);
  114.  
  115. }
  116. }
  117.  
  118.  
  119. if (!ip_exists($user_ip)){
  120. update_count();
  121. ip_add($user_ip);
  122.  
  123. }
  124.  
  125. $count_field="select `count` from `hits_count`";
  126. $run_count_field=mysql_query($count_field)or die (mysql_error());
  127. echo $num_f=mysql_num_rows($run_count_field);
  128.  
  129.  
  130.  
  131. ?>
  132.  
  133. <?php
  134.  
  135. $local='localhost';
  136. $user='root';
  137. $pass='root';
  138. $database='a_database';
  139.  
  140. mysql_connect($local,$user,$pass);
  141. mysql_select_db($database);
  142.  
  143. $user_ip=$_SERVER['REMOTE_ADDR'];
  144.  
  145.  
  146.  
  147. function ip_exists($ip){
  148. global $user_ip;
  149. $query="select `ip` from `hits_ip` where `ip`='$user_ip'";
  150. $query_run=mysql_query($query);
  151. $mysql_num_rows=mysql_num_rows($query_run);
  152. if ($mysql_num_rows==0){
  153. return false;
  154. }else if ($mysql_num_rows>=1){
  155. return true;
  156. }
  157. }
  158.  
  159.  
  160. function ip_add ($ip){
  161. $query="insert into `hits_ip` values('$ip')";
  162. $query_run=mysql_query($query);
  163. }
  164.  
  165.  
  166.  
  167.  
  168. function update_count(){
  169. $query="select `count` from `hits_count`";
  170. if ($query_run=mysql_query($query)){
  171. $count=mysql_result($query_run,0,'count');
  172. $count_inc=$count+1;
  173. $query_update="update `hits_count` set count='$count_inc'";
  174. $mysql_update_run=mysql_query($query_update);
  175.  
  176. }
  177. }
  178.  
  179.  
  180. if (!ip_exists($user_ip)){
  181. update_count();
  182. ip_add($user_ip);
  183.  
  184. }
  185.  
  186. $count_field="select `count` from `hits_count`";
  187. $run_count_field=mysql_query($count_field)or die (mysql_error());
  188. echo $num_f=mysql_num_rows($run_count_field);
  189.  
  190.  
  191.  
  192. ?>
Add Comment
Please, Sign In to add comment