I'm a little stuck - partly with my coding, and partly with some logic ... and I could really do with a fresh opinion on things to help me out of a corner.
I'm working on a project to keep track of my solar electricity generation, and I've ended up with a pretty simple MySQL database with two fields - a date field, and the generation data for that day. The script I'm writing is displaying a monthly graph, showing the daily figures for that month. This graph is generated by calling a Google Graph URL within an <img src='...'> html tag. Initially, the page loads and it's looking great (thanks to the Google graph API), but I want to be able to navigate back and forth through the months.
What I'm wanting to do is have two buttons on the page, "next month" and "previous month", which calls a php function to formulate a new URL string, which then, via javascript, presumably, updates the <img src> graphic accordingly. What I'm really trying to avoid doing, is to reload the entire page whenever I click the button - but instead, only update the graphic using <img src='...'>.
I'm getting in a terrible mess because I'm mixing Javascript (client) code with PHP (server code), and can't work out the logic to make a button call php code which ultimately, updates the graphic through javascript. I've got a basic AJAX implementation working, but the buttons don't cleanly cycle through the months (because the buttons end up being hard-coded with the next and previous months, and don't update accordingly after press number 1).
Any suggestions on how I would approach this? My Javascript skills are extremely limited, which is why I prefer to code in PHP. I feel this must be fairly simple, but I'm just approaching it from the wrong angle!
Many thanks
Ian