My rainfall project produces a MySQL database with a table of rainfall data for several California cities. I have PHP code that can read it and create a table from it in a browser like so.
Modesto Percent of Normal Rainfall
Date | 2014 | 2013 |
21-Dec-14 | 218 | 42 |
22-Dec-14 | 213 | 41 |
23-Dec-14 | 209 | 40 |
24-Dec-14 | 204 | 40 |
25-Dec-14 | 200 | 39 |
26-Dec-14 | 197 | 38 |
27-Dec-14 | 193 | 37 |
28-Dec-14 | 190 | 37 |
30-Dec-14 | 183 | 35 |
31-Dec-14 | 179 | 35 |
01-Jan-15 | 177 | 34 |
02-Jan-15 | 173 | 34 |
03-Jan-15 | 171 | 33 |
04-Jan-15 | 168 | 32 |
05-Jan-15 | 165 | 32 |
06-Jan-15 | 162 | 31 |
07-Jan-15 | 160 | 31 |
08-Jan-15 | 157 | 30 |
09-Jan-15 | 155 | 30 |
10-Jan-15 | 152 | 29 |
11-Jan-15 | 150 | 29 |
12-Jan-15 | 147 | 28 |
13-Jan-15 | 144 | 28 |
14-Jan-15 | 142 | 27 |
15-Jan-15 | 140 | 27 |
16-Jan-15 | 138 | 27 |
17-Jan-15 | 136 | 26 |
Graphing this data has proven problematic in PHP, requiring me to learn javascript in order to use the excellent Google Charts library. Javascript, being browser-side, doesn't integrate well with the MySQL on the server. My first guess at solving this problem is to write a PHP script which produces a CSV string of the rainfall data and have the javascript code read that page in as a string. I then parse the CSV into an array and insert it into the graphing library.
Bite-size pieces. It's all going to have to be done in bite-sized pieces. I just wrote the PHP code to make the CSV. Now it's time to take a mental break and watch the Arsenal-ManU game.
Years ago, I wrote a proof of concept set of web pages that embedded JavaScript insode of PPP inside of perl. Debugging that was difficult.
ReplyDeleteWe went a different direction.
I know what you mean though, we need a language that can do input output and database queries all at the same time.
I'm glad to hear that my problem isn't simple ignorance. From what I'm reading, jQuery with Ajax is the way to go, using the GET function to return my CSV as a string.
ReplyDelete