To debug this, replace your chart type with Table, since a Table should be able to display any data you give it. If you can't get that far, then you need to look in the JavaScript debugger for your browser to find out what it says. If you have a JavaScript syntax error, for example, you won't get very far.
If nothing shows up in the browser when you view the page source, then you probably have a problem on your server side. Hope that helps get you started. On Sat, Aug 20, 2016 at 3:50 PM, <[email protected]> wrote: > @Emily: > > I copied your exact code, changed the database info to my credentials, > changed the SQL query to the fetch the data I needed, and I get a blank > page when opening. There is no graph shown. Is there something I'm missing? > > Thanks, > Andrew > > On Thursday, August 18, 2016 at 8:40:23 AM UTC-4, Emile wrote: >> >> <?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 google-visualization-api@ > googlegroups.com. > 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/af0126ef-d873-4380-b4d9- > 487ab6fd72a5%40googlegroups.com > <https://groups.google.com/d/msgid/google-visualization-api/af0126ef-d873-4380-b4d9-487ab6fd72a5%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- Daniel LaLiberte <https://plus.google.com/100631381223468223275?prsrc=2> [email protected] <[email protected]> 5CC, Cambridge MA -- 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/CAOtcSJM-iA6u8XvdR0GJz4iXFzsF-t0DNAxXjhgw7q%3DV85xEZQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
