A good breakthrough today.  So I didn’t expect to tie the front-end and back-end together until later, but I actually managed to get it up and running without too much grief.  Most of problems I had were simple syntax errors (missing semicolons and such), though turning the the array I pulled from SQL via PHP into a javascript array gave me some difficulty, until I realized I was just over-thinking things.  Here’s the code:

echo ‘<script type = “text/javascript”>’;
echo ‘var firstnames = new Array(“‘, join($firstnames,'”,”‘),'”);’;
echo ‘</script>’;

That’s it!  Then, because Processing.js can use global JS variables, I can easily populate the various variables within my Legislator class with their corresponding data arrays.

I have a very simple demo up at http://lcc.gatech.edu/~tgibes3/ccp_test/ccp_sqltest.php.  All it does is display the name of the moused-over legislator, but it demonstrates that my front-end and back-end setup will work.   Whew!

With this out of the way, I can spend next week working on more layout ideas, with the added piece-of-mind that whatever data I use can easily be placed into my design.

A note on the back-end: It was fairly simple to setup the database – just uploaded a CSV!  I’ll be able to add/remove fields as needed, with almost no limitations to the amount of data I use.

Advertisements