Advertisement
Guest User

at-ms php problem

a guest
May 18th, 2014
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.05 KB | None | 0 0
  1. <?
  2. $sql = 'SELECT `ip_address` FROM `X` '; // read userips
  3.  
  4. if(!$result = $db->query($sql)){die('There was an error running the query [' . $db->error . ']');} // if connection failed
  5. ?>
  6.  
  7. <script type="text/javascript">
  8. //jvectormap data
  9. var visitorsData = {
  10.  
  11. <?php
  12.  
  13. while($row = $result->fetch_assoc()){
  14.              
  15. require_once('widgets/IP2Location.php');
  16.  
  17. // Standard lookup with no cache
  18. $loc = new IP2Location('widgets/IP-COUNTRY-SAMPLE.BIN');
  19.  
  20. $ip = $row['ip_address'];
  21. $record = $loc->lookup($ip, IP2Location::ALL);
  22.  
  23. $countrycode = $record->countryCode ;
  24.  
  25.  
  26. // alle rows einmal durchgehen, ip in countrynamen ändern dann auslesen wie oft (countryname1) vorkommt und dann das hinter (countryname1) echon
  27.  
  28.  
  29.  
  30. //ausgeben
  31. echo json_encode($countrycode); echo': ';echo substr_count($countrycode, $countrycode); //echot die anzahl wie oft $countrycode in $countrycode vorkommt (bisher immer 1x weil jede reihe einzeln gezählt wird)
  32.  
  33. echo','; }?>"CN": 3,};
  34. </script>
  35.    
  36.    
  37. <?
  38.  
  39.  $result->free();    // result freigeben für mehr leistung ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement