flyer automated system
Posted: Sat Sep 11, 2010 11:04 am
Hi everyone
I have a huge problem, i'm stuck with my code
I was already posting my problem on an other forum but they can't solve the problem 
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:
-, this didn't work because every month doesn't have 4 weeks, sometimes 5. So I made something in php that's checking for when i add 4 weeks and it is still in the same month then add a week extra. This solved my problem for every 1ste sunday of the month. But when i try to upload a flyer which is every second saturday, then there's a bug showing up.
- 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
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