<https://lh3.googleusercontent.com/-_bdLhI2zQio/V7WpTTVmiJI/AAAAAAAACbw/RtaWRHyIjkwi1DxrhLd45glhml2qgeK_ACLcB/s1600/graph.png>

<https://lh3.googleusercontent.com/-_bdLhI2zQio/V7WpTTVmiJI/AAAAAAAACbw/RtaWRHyIjkwi1DxrhLd45glhml2qgeK_ACLcB/s1600/graph.png>


 

> <?php
>
> $hostname = "localhost";
> $username = "xxxxxx";
> $password = "xxxxxx";
> $database = "ecb";
> $tabel    = "eurorates";
>
> // Create connection
> $conn = mysqli_connect($hostname, $username, $password, $database);
> // Check connection
> if (!$conn) {
>     die("Connection failed: " . mysqli_connect_error());
> }
>
> //set array variable 
> $results = array();
>
> //talk to the db
> $sql="SELECT * FROM eurorates WHERE currency = 'GBP' ORDER BY date DESC 
> limit 100";
> $result = mysqli_query($conn, $sql);
>
> //count the rows and fields
> $totalRows = mysqli_num_rows($result);
> $totalFields = mysqli_num_fields($result);
>
> //start the loop
> for ( $i = 0; $i < $totalRows; ++$i ) {
>
> //make it 2 dim in case you change your order
>   $results[$i] = mysqli_fetch_array($result); 
>  }
>
> ?>
>
> <html>
>   <head>
>     <script type="text/javascript" 
> src="http://www.google.com/jsapi";></script>
>     <script type="text/javascript">
>       google.load( 'visualization', '1', { 'packages': [ 'corechart' ] } );
>       google.setOnLoadCallback( drawChart );
>       
>       function drawChart() {
>         var data = new google.visualization.DataTable();
>
>         data.addColumn( 'string', 'Datum' );
>         data.addColumn( 'number', 'Rate' );
>
>         data.addRows(100);
>         
>         <?php
>  
>  $i = 0;
>  $numofloops = 100;
>
>  while($i < $numofloops){
>           
>  echo "data.setValue($i, 0, '" . $results[$i]["date"] . "');";
>  echo "data.setValue($i, 1,  " . $results[$i]["rate"] . ");";
>
>  $i++; 
>           }
>         ?>
>    
>         var options = {title: 'Echangerate EUR - GBP',
>                        vAxis: {title: "Rate"},
>                        hAxis: {title: "Date"},
>       colors: ['red','#004411'] 
> };
>
>         var chart = new 
> google.visualization.LineChart(document.getElementById('chart_div'));
>         chart.draw( data, options);
>       }
>     </script>
>   </head>
>   <body>
>     <div id="chart_div" style="width: 1500px; height: 800px;"></div>
>   </body>
> </html>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-visualization-api/d90e8074-a9ca-493f-9907-78c30c779bea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to