Then you're using a nearly identical setup as me except my date doesn't auto update, that;s just a minor detail.
I'm brand new to PHP and web programming too, I don't know the answer off the top of my head, but maybe I can point you in the right direction.
First of all, I think what you need to do is to break up your problem into many small achievable steps. Then you need to do your homework and search out solutions to each of the smaller steps. Once each tiny step is achieved, your overall goal should also work.
1st Step - Get the current date and put in array variable
==========================================
I wouldn't use a single variable, I'd use an array if I were you.
Consider using PHP date() function (
http://ca.php.net/date)
ie: $dateCurrent[year] = current month, $dateCurrent[month], $dateCurrent[day]
Print the variables to test
2nd Step - Calculate the date exactly 1 month prior to current date
==================================================
Again, I would put it in an array instead of a single variable
Use the PHP strtotime() function (
http://ca.php.net/manual/en/function.strtotime.php) in conjunction with the date() function
Ie: $dateLastMonth[year], $dateLastMonth[month], $dateLastMonth[day]
Print the variables to test
3rd Step - Build a SQL query to retrieve dates within a certain range
================================================== =
I think you can use your above query with the addition of a well constructed WHERE phrase. Here;s what you need to do:
1. Retrieve the month and date from your date fields in your database table
ie: "... WHERE month(dateMonth) > $dateLastMonth[month] ..."
2. Construct a WHERE clause using the variable arrays you setup in step 2.
Study these pages:
http://dev.mysql.com/doc/refman/5.0/...functions.html
http://dev.mysql.com/doc/refman/5.0/en/select.html
3. Test your query (print it out) to see if it works
4th Step - Put your results into an array
==============================
Use mysql_fetch_array($result)
Read up on it here:
http://ca3.php.net/mysql_fetch_array
Example: $row = mysql_fetch_array($result)
where $row is an array that contains all of the SQL query results.
You can pass that $row array or use it as needed (pass it onto another functin, print it, further edit it etc...)
5th Step - Use PHP conditional statements to modify $row as needed
================================================== =
Before you continue, make sure that the $row array contains all the database table that you need.
Once you verified this then you can use PHP's conditional statements to manipulate the data as needed using if ... then ... else, switch ... case ... break, == != > < etc...
Once you've completed this step, print results to test it works to your satisfaction
6th Step - UPDATE sql database
========================
Finally, once step 5 works, then you're ready to UPDATE your SQL table.
Built a query as needed using UPDATE
Read up on MySQL "UPDATE" here:
http://dev.mysql.com/doc/refman/5.0/en/update.html
================================================
Anyways, hopefully this points you in the right direction. I still think the key break it down into as many time steps as possible. If you problem-solve each little step on it's own, and make sure each one works before you proceed to the next, I think you'll find that the bigger goal is achievable.
PS when working with dates I try to make it a habit to use only numerical data and not alpha, (ie: "12" instead of "December"). It's easier to use conditional statements with numerical data. All I do is simply convert a numerical date data to alpha when it's time to display it.