Sean’s Obsessions

Sean Walberg’s blog

Hacking PHP Hacks

I’ve had Jack Herrington’s PHP Hacks around for a while, always refering to it, but never getting around to using it. There were two hacks that really caught my eye, one made a DHTML graph that did a scatterplot of data letting you choose the X and Y axes, and the colour and size of the dots. The other showed how to use JSON to easily get data from a PHP structure to an AJAX application. After seeing both of them, I thought that integrating the two would be really helpful – pulling results in a PHP program and manipulating them through an AJAX application.

So, last night I sat down to do it. It wasn’t as easy as I had thought, largely because the graphing hack was fairly specific to the dataset he used. For example, the columns are predefined, and my code dynamically determines what the columns are. This isn’t so bad, but the way the selection boxes were done needed the data when the page was loaded, but because I’m doing the AJAX thing, it’s not available until after.

Still a bit of work to go but I think for the purpose I have in mind I don’t need to take it any further.

json_graph.tgz

Comments

I’m trying something new here. Talk to me on Twitter with the button above, please.