I have seen references to this but no solutions that I could find so
here is a working example using
the PHP 5 function "json_encode".
this is working well for Exhibit but I'm still having problems when
loading a timeline, I get an error
"TypeError: this._timeline is undefined" .
anyway I thought I would share what I have so far
cut the below and save as "my_phpfile.php":
======
<?php
$mysql = mysql_connect('localhost', 'root', 'password');
mysql_select_db('mydatabase');
$query = 'select * from mytable';
$res = mysql_query($query);
// iterate over every row
while ($row = mysql_fetch_assoc($res)) {
// for every field in the result..
for ($i=0; $i < mysql_num_fields($res); $i++) {
$info = mysql_fetch_field($res, $i);
$type = $info->type;
// cast for real
if ($type == 'real')
$row[$info->name] = doubleval($row[$info->name]);
// cast for int
if ($type == 'int')
$row[$info->name] = intval($row[$info->name]);
}
$rows[] = $row;
}
// display as JSON all rows together as one big array
echo '{"items": ';
echo json_encode($rows);
echo '}';
mysql_close($mysql);
?>
======
after you have some data in your mysql database
place the above php file in a folder on your website and test it by
loading it in your browser and you should see the json data, once you
have confirmed it works then modify your html page (that reside in the
same folder) to :
<link href="my_phpfile.php" type="application/json" rel="exhibit/
data" />
so have fun! that's all there is to it :)
If anyone has any ideas on the Timeline error I would be pleased to
hear about them.
you can see the presidents example here:
http://courtenay.widget-it.com/presidents/index.html
you can see the the json encoded data here:
http://courtenay.widget-it.com/presidents/bip.php
you can download the mysql backup of presidents here:
http://courtenay.widget-it.com/presidents/presidents.sql