Jump to content

Google API Table Sisualization Issues


paulman888888

Recommended Posts

Hi;

 

First Off thank-you for reading my post.

<?
$header_scripts.='<script type=\'text/javascript\' src=\'http://www.google.com/jsapi\'></script>
    <script type=\'text/javascript\'>
      google.load(\'visualization\', \'1\', {packages:[\'table\']});
      google.setOnLoadCallback(drawTable);
      function drawTable() {
        var data = new google.visualization.DataTable();
        data.addColumn(\'string\', \'Event Name\');
        data.addColumn(\'string\', \'Date\');
        data.addColumn(\'string\', \'Postcode\');
data.addColumn(\'string\', \'Distance (From: '.$userpostcode.')\');
data.addColumn(\'string\', \'View More\');';

$query = "SELECT * FROM chess_event ";
$result = mysql_query($query)or die(mysql_error()); 
$i=0;
$header_scripts.="\r\n".'data.addRows('.mysql_num_rows($result).');'."\r\n";
while($row = mysql_fetch_array($result)){
$header_scripts.='data.setCell('.$i.', 0, \''.$row['name'].'\');'."\r\n";
$header_scripts.='data.setCell('.$i.', 1, \''.$row['day'].'\');'."\r\n";
$header_scripts.='data.setCell('.$i.', 2, \''.$row['postcode'].');\''."\r\n";
$header_scripts.='data.setCell('.$i.', 3, \''.get_latlong_from_postcodes($userpostcode, $row['postcode']).'\');'."\r\n";
$header_scripts.='data.setCell('.$i.', 4, \'<a href="link">More</a>\');'."\r\n";


$i++; // increment counter
}
$header_scripts.='var table = new google.visualization.Table(document.getElementById(\'table_div\'));
       table.draw(data, {showRowNumber: true});
      }
    </script>';$body.='<div id="table_div">Loading! Please Wait...</div>';?>

Above is my PHP code

Below is the output <script>

<script type='text/javascript' src='http://www.google.com/jsapi'></script>
    <script type='text/javascript'>
      google.load('visualization', '1', {packages:['table']});
      google.setOnLoadCallback(drawTable);
      function drawTable() {
        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Event Name');
        data.addColumn('string', 'Date');
        data.addColumn('string', 'Postcode');
data.addColumn('string', 'Distance (From: SW10)');
data.addColumn('string', 'View More');
data.addRows(2);
data.setCell(0, 0, 'Test Event 4');
data.setCell(0, 1, '2010-02-15');
data.setCell(0, 2, 'Dn16);'
data.setCell(0, 3, '148 miles');
data.setCell(0, 4, '<a href="LINK">More</a>');
data.setCell(1, 0, 'Test Event 3');
data.setCell(1, 1, '2009-01-01');
data.setCell(1, 2, 'Dn16);'
data.setCell(1, 3, '148 miles');
data.setCell(1, 4, '<a href="LINK">More</a>');
var table = new google.visualization.Table(document.getElementById('table_div'));
       table.draw(data, {showRowNumber: true});
      }
    </script>

 

Please Can Someone tell me what i have done wrong.

 

Thank-you All

Paul

Link to comment
Share on other sites

Sorry; your right.

 

Well i have been trying to use Google Visulisation API but its not going very well, i copyed the demo from Google and edited to PHP. It doesn't work at all.

 

I have done everything (that i can think of as well other people ideas) but it just won't work.

 

Thank-you

Paul

 

Sorry once again for the 1st bad post, i was so into the ''Zone'' trying to fix the problem.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.