Jump to content


Photo

Filter Expired Classified Ad Listings


  • Please log in to reply
3 replies to this topic

#1 ppunk

ppunk
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 06 July 2006 - 06:23 PM

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

#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 06 July 2006 - 06:30 PM

I would do it as a time diffrence

example

$start_date=date("dmy");

$end_date=date("dmy");

if($start_date>$end_date){

echo users info

elseif ($end_date - $start_date) {

insert to another table to be shown as an arcive

}
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 ppunk

ppunk
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 07 July 2006 - 03:03 PM

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

#4 designationlocutus

designationlocutus
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts

Posted 07 July 2006 - 03:11 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users