ppunk Posted July 6, 2006 Share Posted July 6, 2006 Hi, I am setting up an area on my site where users can post their own items they want to sell or give away, similar to a classified ad. I am having problems setting it up so it filters only active items. I want to set up the form so it allows the user to choose how many days their listing will be online (similar to ebay), like 7, 14, or 28 days as an example. After their item listing is expired, I want it so it is taken off the main site and put into an archive database table.The only way I can think of doing this is to either put the code on the main listing page so it is run everytime someone views that page, or to set up a cron job to run every once in awhile. Items don't need to be taken down immediately, so in the case of me setting up a cron job to run every 6 six hours to check for expired items would be fine.My main problem is, setting up the SQL and PHP to accomplish all this. I have had some help from some great members here, but I am still having trouble getting this to work properly and more importantly, actually learning how it works.In my items database table, here are the fields I have right now:id, startDate, endDate, type, summary (there are some more fields but they are irrelevant here).Any help or tips would be great! Thanks for any help in advance.-Steve Quote Link to comment https://forums.phpfreaks.com/topic/13876-filter-expired-classified-ad-listings/ Share on other sites More sharing options...
redarrow Posted July 6, 2006 Share Posted July 6, 2006 I would do it as a time diffrence example$start_date=date("dmy");$end_date=date("dmy");if($start_date>$end_date){echo users infoelseif ($end_date - $start_date) {insert to another table to be shown as an arcive} Quote Link to comment https://forums.phpfreaks.com/topic/13876-filter-expired-classified-ad-listings/#findComment-54045 Share on other sites More sharing options...
ppunk Posted July 7, 2006 Author Share Posted July 7, 2006 I should have mentioned that I am not that advanced with php (yet). I am still learning little by little. Is there anyway to explain a little more about how this can be done? You mentioned to do it as a time difference. Would it be a good idea to have the time included with the date? Right now my startDate and endDate are set up like this in my MySQL database: 2006-07-10.Any help would be great.Thanks for the reply!-Steve Quote Link to comment https://forums.phpfreaks.com/topic/13876-filter-expired-classified-ad-listings/#findComment-54412 Share on other sites More sharing options...
designationlocutus Posted July 7, 2006 Share Posted July 7, 2006 I think the Cron job would be the best bet. Changing by page access would be unreliable if no-one visits the page.Another solution would be to run a script that compares end date to today every time you add/edit/delete in your classified admin section, and then sets the status of the ad to inactive. Quote Link to comment https://forums.phpfreaks.com/topic/13876-filter-expired-classified-ad-listings/#findComment-54417 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.