login  Naam:   Wachtwoord: 
Registreer je!
 Forum

array geeft maar 1 waarde ? (jpgraph)

Offline merlin_nl - 10/07/2006 21:01
Avatar van merlin_nlPHP interesse Ik probeer met het volgende stuk script een array te voeren naar jpgraph.
Echter krijg ik nu met dit script continu 1 waarde "1".

Zou iemand hier meer info over weten ?

  1. <?php
  2. include ("jpgraph-1.20.4/src/jpgraph.php");
  3. include ("jpgraph-1.20.4/src/jpgraph_bar.php");
  4.  
  5. $host = "";
  6. $user = "";
  7. $bdd = "";
  8. $password = "";
  9. mysql_connect($host, $user,$password) or die("erreur de connexion au serveur");
  10. mysql_select_db($bdd) or die("erreur de connexion a la base de donnees");
  11.  
  12. $data1y = "";
  13.  
  14. $tellerledenday = date('d');
  15. $tellerledenmonth = date('m');
  16. $tellerledenyear = date('y');
  17.  
  18. if($tellerledenmonth=="01"){ $maxday = 31; }
  19. elseif($tellerledenmonth=="02"){ $maxday = 28; }
  20. elseif($tellerledenmonth=="03"){ $maxday = 31; }
  21. elseif($tellerledenmonth=="04"){ $maxday = 30; }
  22. elseif($tellerledenmonth=="05"){ $maxday = 31; }
  23. elseif($tellerledenmonth=="06"){ $maxday = 30; }
  24. elseif($tellerledenmonth=="07"){ $maxday = 31; }
  25. elseif($tellerledenmonth=="08"){ $maxday = 31; }
  26. elseif($tellerledenmonth=="09"){ $maxday = 30; }
  27. elseif($tellerledenmonth=="10"){ $maxday = 31; }
  28. elseif($tellerledenmonth=="11"){ $maxday = 30; }
  29. else { $maxday = 31; }
  30. $aantal = $maxday;
  31. for($a=1;$a<=$aantal;$a++){
  32. if($a<=9) { $dag = "0" . $a; } else { $dag = $a; }
  33. $query = "SELECT SUM(hits) AS hits FROM ledenstats WHERE toid = '1' AND day = '$dag' AND month = '$tellerledenmonth' AND year = '$tellerledenyear' ORDER BY time DESC";
  34. $result = mysql_fetch_assoc(mysql_query($query));
  35.  
  36. if($result["hits"] == "") {
  37. $hits = 0;
  38. } else {
  39. $hits = $result["hits"];
  40. }
  41. $hit = "".$hits.",";
  42. $data1ytemp .= $hit;
  43. }
  44. $data1y = "".$data1ytemp."0";
  45. //echo $data1y;
  46. //echo $data1y;
  47. // Create the graph. These two calls are always required
  48. $graph = new Graph(480,200,"auto");
  49. $graph->SetScale("textlin");
  50.  
  51. //$graph->SetShadow();
  52. $graph->img->SetMargin(40,30,20,40);
  53.  
  54. $graph->SetBackgroundImage("jpgraph-1.20.4/src/Examples/tiger_bkg.png",BGIMG_COPY);
  55.  
  56. // Create the bar plots
  57. $b1plot = new BarPlot($data1y);
  58. $b1plot->SetFillGradient("forestgreen","springgreen",GRAD_HOR);
  59.  
  60.  
  61. // Create the grouped bar plot
  62. $gbplot = new GroupBarPlot(array($b1plot));
  63.  
  64. // ...and add it to the graPH
  65. $graph->Add($gbplot);
  66.  
  67. $graph->title->Set("Profielbezoek");
  68. $graph->xaxis->title->Set("Dag");
  69. $graph->yaxis->title->Set("Aantal");
  70.  
  71. $graph->title->SetFont(FF_FONT1,FS_BOLD);
  72. $graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
  73. $graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
  74.  
  75. // Display the graph
  76. $graph->Stroke();
  77. ?>



TABLE :
  1. CREATE TABLE `ledenstats` (
  2. `id` int(20) NOT NULL auto_increment,
  3. `toid` int(11) NOT NULL default '1',
  4. `fromid` int(11) NOT NULL default '1',
  5. `hits` int(20) NOT NULL default '1',
  6. `time` int(5) NOT NULL default '0',
  7. `day` char(2) NOT NULL default '',
  8. `month` char(2) NOT NULL default '',
  9. `year` char(2) NOT NULL default '',
  10. PRIMARY KEY (`id`)
  11. ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=40486 ;

0 antwoorden

Gesponsorde links
Er zijn nog geen reacties op dit bericht.
Dit onderwerp is gesloten.
Actieve forumberichten
© 2002-2025 Sitemasters.be - Regels - Laadtijd: 0.185s