I have a huge problem, i'm stuck with my code
But first let me explain the main problem from the beginning.
There's a guy with his salsa-site (http://www.sabortropical.be/flyers.htm). He has a flyer section as you can see in the url. Now he has to input every flyer manually, by copy-pasting html and edit the things that have to be edited.
He came to me, if it could be automated. So we had a talk about the features etc. I started coding a small system. In the system he can upload a flyer with data (data + image uploading), this works all fine (http://gyazo.com/33c229f8ac3fd46e9d7dbbaf42cca02e.png). (In the dropdown you can chose every week, every 2 weeks, every month)
He can edit, delete, etc. Now I'm running a cronjob every night to see if the date of the flyer is expired and then I'm putting it in an archive. If it is in the archive, you can put it back by just editing the date and the data + image is back online.
Now he told me, he didn't like it because he wants to upload it all at once (in one day for whole year). There are flyers which have to be repeated. Every first sunday of the month, every second sunday of the month, every month, etc.
First I used a unix timestamp-field in my database for the date, they (guys on the other forum) suggested me to use date-field because you can use mysql's functions.
Now they came with a couple solutions that didn't work:
-
Code: Select all
$query = "SELECT ADDDATE("2010-09-05, INTERVAL 4 WEEK) FROM test";- another solutions that someone gave was:
http://gyazo.com/60d496759f933250e899e2a47643ca38.png
This is actually the same as i coded in php, but now all in SQL. He suggested this (it's PostgreSQL) and that I had to convert it into Mysql, but I can't get it working.
But I think it will give me the same bug with every second saturday.
Example of correct dates:
september 2nd saturday = 2010-09-11
october 2nd saturday = 2010-10-09
november 2nd saturday = 2010-11-13
Example of my system's return values
september : 2010-09-11 (input date)
october: 2010-10-09 (It adds to 4 weeks, checks if the month is different from the previous, which is true, so adds no extra week -> answer correct)
november: 2010-11-06 (Here it does the same as in october, checks the month, it's not the same month, now it's november, so it doesn't add extra week.)
BUT NOW IT SHOULD, this is my problem, can't get this fixed
Hopefully you guys can help me. Greetz