You attachment is still pending, so here goes, this is roughly how you would generate the queries to get the data from your db, there are different methods you can use, but this is should give you the general idea.
Your form could look like this:
<form action="xxx" method=GET>
<select name=year>
<option value="2012">2012</option>
<option value="2011">2011</option>
</select>
<select name=month>
<option value="1">Jan</option>
<option value="2">Feb</option>
</select>
<input type=submit />
</form>
This would create a query string something like this:
?year=2011&month=2
Your form handler (the action set out in xxx from your form) then accesses these variables:
// use int to cast the variable to an integer
$year = (int)$_GET['year'];
$month = (int)$_GET['month'];
// do some basic filtering here
// if $year is > this year or < x years and therefore out of range
// then get rid of this user
// if month is not 1 or greater and 12 or less
// then get rid of this user
// If you got here, build the query based on those incoming variables
$sql = "select data from mytable where year = '$year' and month = '$month'";
echo $sql;
… you then present the data in the graph, which you say you have already worked out how to do.
This is the simplest way I can think of to show you the flow between a HTML form and the query builder, clearly your final solution will be far more complex than this.
If this is still a mystery to you, then you should make some test files and practice posting data back and forth, and use var_dump($_GET) to see how the form elements behave and how their information is interpreted.
I have kept the example short, and have not shown things like:
- using POST instead of GET method
- how to check if variables were sent
- how to use prepared statements to protect your db
- error handling
- header relocations to get rid of the user
Either show us how you get on, or ask (or search) for advice on these matters …
ps I’d favour sticking with GET because this means people can bookmark a set of data, they can share it, you can cache it, you can also look in your logfiles to find out which queries are the most popular – all of which may be irrelevant to you – but I certainly used this to great effect when I did something similar for an air quality application.