Re: Mysql / Array / Graph , HELP !

From: Date: Wed, 05 Jul 2000 14:17:09 +0000
Subject: Re: Mysql / Array / Graph , HELP !
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-4944@lists.php.net to get a copy of this message
On Wed, 5 Jul 2000, Eric FEILLANT wrote: Your data handling is not correct. See below. > Hi, > > I still have a problem with my php programm. > I want to graph the traffic IN and OUT of each day of the month > selected. > But , I only get the first point of the graph line on the screen. > > Perhaps have i an error in my while loop ? > > Here's my mysql DB: > > +------------+----------+-----------------+----------+----------+----------+-----------+ > > | date | heure | pix | inoctet | outoctet | > chargein | chargeout | > +------------+----------+-----------------+----------+----------+----------+-----------+ > > | 2000-06-30 | 12:00:00 | ROUEN | 18573990 | 5831925 | > 16.12 | 5.06 | > | 2000-06-30 | 14:00:00 | ROUEN | 18031659 | 35949349 | > 15.65 | 31.21 | > | 2000-06-30 | 15:00:00 | ROUEN | 17996431 | 33180640 | > 15.62 | 28.80 | > | 2000-06-30 | 16:00:00 | ROUEN | 18014522 | 25952332 | > 15.64 | 22.53 | > | 2000-06-30 | 17:00:00 | ROUEN | 14794481 | 32014239 | > 12.84 | 27.79 | > | 2000-06-30 | 18:00:00 | ROUEN | 16738895 | 32647380 | > 14.53 | 28.34 | > | 2000-06-30 | 19:00:00 | ROUEN | 15996825 | 32842938 | > 13.89 | 28.51 | > | 2000-06-30 | 20:00:00 | ROUEN | 18344561 | 23346540 | > 15.92 | 20.27 | > | 2000-06-30 | 21:00:00 | ROUEN | 14013771 | 12450367 | > 12.16 | 10.81 | > | 2000-06-30 | 22:00:00 | ROUEN | 8226492 | 556770 | > 7.14 | 0.48 | > | 2000-06-30 | 23:00:00 | ROUEN | 3638084 | 250000 | > 3.16 | 0.22 | > +------------+----------+-----------------+----------+----------+----------+-----------+ > > And my PHP program.....=> > > <?php > $cnx = mysql_connect(localhost,root); > $sql = "SELECT dayofmonth(date),SUM(inoctet),SUM(outoctet) from smtp > where month(date) = '06' group by date"; > $result = mysql_db_query(fwparis, $sql, $cnx); > include('/usr/local/apache/docs/classes/class.graph'); > > while($row = mysql_fetch_array($result)) > { > $r1 = $row["dayofmonth(date)"]; > $r2 = $row["SUM(inoctet)"]; > $r3 = $row["SUM(outoctet)"]; > $a = array($r1,$r2,$r3); should be the following, $r1 = $r2 = $r3 = array(); while($row = mysql_fetch_array($result)) { $r1[] = $row["dayofmonth(date)"]; $r2[] = $row["SUM(inoctet)"]; $r3[] = $row["SUM(outoctet)"]; } $a = array($r1,$r2,$r3); .... HZ > phpplot(array( > "box_showbox"=> true, > "grid"=> true, > "grid_xgrid" => false, > "title_text"=> "Traffic Graph", > "yaxis_labeltext"=> "Traffic", > "xaxis_labeltext"=> "Jour", > "legend_shift"=> array(-300,10), > "size"=> array(800,950) )); > > phpdata($a); > > phpdraw("linepoints",array( > "drawsets" => array(1,2), > "legend"=> array("IN", > "OUT"), > "showpoint"=> true, > "showvalue"=> true )); > > phpshow(); > } > ?> > ~ > > You can find the class.graph at VH CONSULTANTS: > http://www.vhconsultants.com > > Thanks for help, > > > >

« previous php.general (#4944) next »