[ Index ]
 

Code source de phpMyVisites 2.3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/plugins/clickheat/libs/examples/ -> fromdatabase.php (source)

   1  <?php
   2  /**
   3   * Exemple d'utilisation de la classe HeatmapFromDatabase
   4   * Use example of HeatmapFromDatabase class
   5   * 
   6   * Table utilisée pour ce test / Used table for this test:
   7  
   8  CREATE TABLE `CLICKS` (
   9    `CLICK_X` smallint(5) unsigned NOT NULL,
  10    `CLICK_Y` smallint(5) unsigned NOT NULL,
  11    KEY `CLICK_Y` (`CLICK_Y`)
  12  ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
  13  
  14  INSERT INTO `CLICKS` (`CLICK_X`, `CLICK_Y`) VALUES (10, 10),(20, 20),(30, 30),(40, 40),(50, 50),(60, 60),(70, 70),(80, 80),(90, 90),(100, 100),(110, 110),(120, 120),(130, 130),(140, 140),(150, 150),(160, 160),(170, 170),(180, 180),(190, 190);
  15  
  16  **/
  17  ?>
  18  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  19  <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
  20  <head>
  21      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  22      <title>ClickHeat | Examples</title>
  23  </head>
  24  <body>
  25  <?php
  26  exit('Enlevez cette ligne pour que ce fichier marche/Remove this line to make this file work');
  27  
  28  include  './../classes/Heatmap.class.php';
  29  include  './../classes/HeatmapFromDatabase.class.php';
  30  
  31  $heatmap = new HeatmapFromDatabase();
  32  /**
  33   * Requête (CLICK_Y se doit d'avoir un index pour de bonnes performances, voir EXPLAIN dans le manuel MySQL)
  34   * The query (CLICK_Y should have an index for good performances, see EXPLAIN in MySQL manual)
  35  **/
  36  $heatmap->query = 'SELECT CLICK_X, CLICK_Y FROM CLICKS WHERE CLICK_Y BETWEEN %d AND %d';
  37  $heatmap->maxQuery = 'SELECT MAX(CLICK_Y) FROM CLICKS';
  38  $heatmap->database = 'test';
  39  $heatmap->user = 'test';
  40  $heatmap->password = 'test';
  41  /** Fichiers temporaires / Temporary files */
  42  $heatmap->cache = '.';
  43  /** Fichiers générés / Generated files */
  44  $heatmap->path = '.';
  45  /** Fichier final / Final file */
  46  $heatmap->file = 'resultfromdb-%d.png';
  47  /**
  48   * On force la hauteur finale (attention à la consommation mémoire dans ce cas !)
  49   * Forcing final height (take care of the memory consumption in such case!)
  50  **/
  51  $images = $heatmap->generate(200, 100);
  52  echo 'Résultats/Results: ';
  53  if ($images === false)
  54  {
  55      echo 'error: '.$heatmap->error;
  56  }
  57  else
  58  {
  59      echo '<pre>';
  60      print_r($images);
  61      echo '</pre>';
  62  
  63      echo '<br /><br /><p style="line-height:0;">';
  64      for ($i = 0; $i < $images['count']; $i++)
  65      {
  66          echo '<img src="', $images['filenames'][$i], '" width="', $images['width'], '" height="', $images['height'], '" alt="" /> Image ', $i, '<br />';
  67      }
  68      echo '</p>';
  69  }
  70  ?>
  71  </body>
  72  </html>


Généré le : Mon Nov 26 14:10:01 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics