login  Naam:   Wachtwoord: 
Registreer je!
 Forum

mijn teller stopt bij 1

Offline keesgerbers - 23/01/2006 19:09
Avatar van keesgerbersLid ik heb een teller (met hulp) gemaakt en hij telt alleen 1 bezoeker en daarna doet hij niets meer
hier staat de teller http://www.vvmaasbracht.nl/vierkant.php
(database wachwoorden heb ik weggelaten)
ik zet de codes er ook bij hier staan ze

bezoekers/index.php
  1. <?php
  2.  
  3.  
  4.  
  5.  
  6. include("config.php");
  7.  
  8. mysql_connect($conf['MysqlHost'], $conf['MysqlUser'], $conf['MysqlPass']);
  9. mysql_select_db($conf['MysqlDb']);
  10. ?>
  11. <html>
  12.  
  13. <head>
  14. <title>Statistieken :: <?php echo $conf['Titel']; ?></title>
  15. <style>
  16. body, td { font-family: Verdana; font-size: x-small; }
  17. </style>
  18. </head>
  19.  
  20. <body>
  21.  
  22. <center>
  23. <?php
  24. if($conf['Totaal']) {
  25. $query = mysql_query("SELECT * FROM stats GROUP BY ip") or die(mysql_error());
  26. $uhits = mysql_num_rows($query);
  27.  
  28. $hits = mysql_result(mysql_query("SELECT sum(hits) as total FROM stats"), 0, "total");
  29.  
  30. $query = mysql_query("SELECT * FROM stats GROUP BY datum") or die(mysql_error());
  31. $delen = mysql_num_rows($query);
  32.  
  33. $total = $uhits + $hits;
  34.  
  35. $bar1 = round($hits / $total * 100);
  36. $bar2 = round($uhits / $total * 100);
  37. ?>
  38. <table border="0" cellpadding="5" cellspacing="0" width="100%" style="border: 1px solid #DDDDDD;">
  39. <tr>
  40. <td colspan="2" style="border-bottom: 1px dashed #DDDDDD;" bgcolor="#EFEFEF"><b>Totaal</b></td>
  41. </tr>
  42. <tr>
  43. <td width="140">Hits: (<?php echo $hits; ?>)</td>
  44. <td><img src="bar_line.gif" width="1" height="15"><img src="bar_1.gif" width="<?php echo $bar1; ?>%" height="15"><img src="bar_line.gif" width="1" height="15"><img src="bar_2.gif" width="<?php echo $bar2 - 1; ?>%" height="15"><img src="bar_line.gif" width="1" height="15"></td>
  45. </tr>
  46. <tr>
  47. <td width="140" bgcolor="#EFEFEF">Unieke hits: (<?php echo $uhits; ?>)</td>
  48. <td bgcolor="#EFEFEF"><img src="bar_line.gif" width="1" height="15"><img src="bar_1.gif" width="<?php echo $bar2; ?>%" height="15"><img src="bar_line.gif" width="1" height="15"><img src="bar_2.gif" width="<?php echo $bar1 - 1; ?>%" height="15"><img src="bar_line.gif" width="1" height="15"></td>
  49. </tr>
  50. </table>
  51. <br>
  52. <?php
  53. }
  54.  
  55. $select1 = mysql_query("SELECT * FROM stats GROUP BY datum ORDER BY datum DESC LIMIT 0,".$conf['Limit']) or die (mysql_error());
  56.  
  57. while($get = mysql_fetch_object($select1)) {
  58. $select = mysql_query("SELECT * FROM stats WHERE datum = '".$get->datum."'") or die (mysql_error());
  59. $uhits = mysql_num_rows($select);
  60.  
  61. $hits = mysql_result(mysql_query("SELECT sum(hits) as total FROM stats WHERE datum = '".$get->datum."'"), 0, "total");
  62.  
  63. $total = $uhits + $hits;
  64.  
  65. $bar1 = $hits / $total * 100;
  66. $bar2 = $uhits / $total * 100;
  67.  
  68. $date = explode("-", $get->datum);
  69. ?>
  70. <table border="0" cellpadding="5" cellspacing="0" width="100%" style="border: 1px solid #DDDDDD;">
  71. <tr>
  72. <td colspan="2" style="border-bottom: 1px dashed #DDDDDD;" bgcolor="#EFEFEF"><b><?php echo $date[2]."-".$date[1]."-".$date[0]; ?></b></td>
  73. </tr>
  74. <tr>
  75. <td width="140">Hits: (<?php echo $hits; ?>)</td>
  76. <td><img src="bar_line.gif" width="1" height="15"><img src="bar_1.gif" width="<?php echo $bar1; ?>%" height="15"><img src="bar_line.gif" width="1" height="15"><img src="bar_2.gif" width="<?php echo $bar2 - 1; ?>%" height="15"><img src="bar_line.gif" width="1" height="15"></td>
  77. </tr>
  78. <tr>
  79. <td width="140" bgcolor="#EFEFEF">Unieke hits: (<?php echo $uhits; ?>)</td>
  80. <td bgcolor="#EFEFEF"><img src="bar_line.gif" width="1" height="15"><img src="bar_1.gif" width="<?php echo $bar2; ?>%" height="15"><img src="bar_line.gif" width="1" height="15"><img src="bar_2.gif" width="<?php echo $bar1 - 1; ?>%" height="15"><img src="bar_line.gif" width="1" height="15"></td>
  81. </tr>
  82. </table>
  83. <br>
  84. <?php
  85. }
  86. ?>
  87. </center>
  88.  
  89. </body>
  90.  
  91. </html>


bezoekers/stats.php
  1. <?php
  2. include("config.php");
  3.  
  4. mysql_connect('localhost','prive','prive');
  5. mysql_select_db('prive');
  6.  
  7. $query = mysql_query("SELECT * FROM stats WHERE ip = '".$_SERVER['REMOTE_ADDR']."' AND datum = '".date("Y-m-d")."'") or die(mysql_error());
  8. $count = mysql_num_rows($query);
  9.  
  10. if($count == 0) {
  11. $query = "INSERT INTO stats (ip, datum, hits) VALUES ('".$_SERVER['REMOTE_ADDR']."', '".date("Y-m-d")."', '1')";
  12. } else {
  13. $obj = mysql_fetch_object($query);
  14. $hits = $obj->hits + 1;
  15. $query = "UPDATE stats SET hits = '".$hits."' WHERE ip = '".$_SERVER['REMOTE_ADDR']."' AND datum = '".date("Y-m-d")."'";
  16. }
  17.  
  18. mysql_query($query) or die(mysql_error());
  19. ?>


bezoekers.php

  1. <html>
  2. <head>
  3. <title>Untitled Document</title>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  5. </head>
  6.  
  7. <body>
  8. <?php
  9.  
  10.  
  11. include("bezoekers/config.php");
  12.  
  13. mysql_connect($conf['MysqlHost'], $conf['MysqlUser'], $conf['MysqlPass']);
  14. mysql_select_db($conf['MysqlDb']);
  15. ?>
  16. <html>
  17.  
  18. <head>
  19. <title>Statistieken :: <?php echo $conf['Titel']; ?></title>
  20. <style>
  21. body, td { font-family: Verdana; font-size: x-small; }
  22. </style>
  23. </head>
  24.  
  25. <body>
  26.  
  27. <center>
  28. <?php
  29. if($conf['Totaal']) {
  30. $query = mysql_query("SELECT * FROM stats GROUP BY ip") or die(mysql_error());
  31. $uhits = mysql_num_rows($query);
  32.  
  33. $hits = mysql_result(mysql_query("SELECT sum(hits) as total FROM stats"), 0, "total");
  34.  
  35. $query = mysql_query("SELECT * FROM stats GROUP BY datum") or die(mysql_error());
  36. $delen = mysql_num_rows($query);
  37.  
  38. $total = $uhits + $hits;
  39.  
  40. $bar1 = round($hits / $total * 100);
  41. $bar2 = round($uhits / $total * 100);
  42. ?>
  43. aantal bezoekers vanaf 21-12-05: <font color="#00FF00"><br><?php echo $uhits; ?></font>
  44. <br>
  45. <?php
  46. }
  47.  
  48. $select1 = mysql_query("SELECT * FROM stats GROUP BY datum ORDER BY datum DESC LIMIT 0,".$conf['Limit']) or die (mysql_error());
  49.  
  50. while($get = mysql_fetch_object($select1)) {
  51. $select = mysql_query("SELECT * FROM stats WHERE datum = '".$get->datum."'") or die (mysql_error());
  52. $uhits = mysql_num_rows($select);
  53.  
  54. $hits = mysql_result(mysql_query("SELECT sum(hits) as total FROM stats WHERE datum = '".$get->datum."'"), 0, "total");
  55.  
  56. $total = $uhits + $hits;
  57.  
  58. $bar1 = $hits / $total * 100;
  59. $bar2 = $uhits / $total * 100;
  60.  
  61. $date = explode("-", $get->datum);
  62. ?>
  63. <?php
  64. }
  65. ?>
  66. </center>
  67.  
  68. </body>
  69.  
  70. </html>


bezoekers/config.php
  1. <?php
  2. $conf['MysqlHost'] = "localhost"; // Mysql host (meestal localhost)
  3. $conf['MysqlUser'] = "prive"; // Mysql gebruiker
  4. $conf['MysqlPass'] = "prive"; // Mysql wachtwoord
  5. $conf['MysqlDb'] = "prive"; // Mysql database
  6.  
  7. ###########################################
  8.  
  9. $conf['Titel'] = "RKVV Maasbracht"; // Titel van je site
  10. $conf['Totaal'] = TRUE; // TRUE als hij het totaal moet laten zien en FALSE als dat niet moet
  11. $conf['Limit'] = 30; // Van hoeveel dagen moet hij de statistieken laten zien
  12. ?>

3 antwoorden

Gesponsorde links
Offline webstab - 23/01/2006 19:12 (laatste wijziging 23/01/2006 19:12)
Avatar van webstab PHP ver gevorderde Kijk even wat er in je database staat. Dan kan je ziet of het aan het ingeven ligt of aan het weergeven.

PS: Je kan misschien volgende keer je codes ergens anders posten of de html eruit knippen, dit is niet bepaald handig werken.
Offline nathanael - 23/01/2006 20:16
Avatar van nathanael Gouden medaille

HTML gevorderde
het ligt aan dit stukje code in stats.php

  1. <?php
  2. } else {
  3. $obj = mysql_fetch_object($query);
  4. $hits = $obj->hits + 1;
  5. $query = "UPDATE stats SET hits = '".$hits."' WHERE ip = '".$_SERVER['REMOTE_ADDR']."' AND datum = '".date("Y-m-d")."'";
  6. }
  7. ?>

Je kan simpel alleen de var $query uitvoeren zonder eerst te fetchen.
dan wordt het
  1. $query = "UPDATE stats SET hits = hits +1 WHERE ip = '".$_SERVER['REMOTE_ADDR']."' AND datum = '".date("Y-m-d")."'";

ik denk dat ie het zo wel doet
Offline keesgerbers - 23/01/2006 21:38
Avatar van keesgerbers Lid hij werkt nu

heel erg bedankt
Gesponsorde links
Dit onderwerp is gesloten.
Actieve forumberichten
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.312s