Jump to content

Recommended Posts

Hi Everyone,

 

Im looking for a bit of advice.

 

Im working on an auction script. Currently when an item is sent to auction, the status is set to "At auction". Is it possible that when the auctions ends that i can automatically update the database to change the status to "Auction Won" or "Auction Lost"?

 

Or would i have to execute a query when the user opens the page displaying the data?

 

Something like...

 

if ($date > $end_date) {
mysql_query("UPDATE auction SET status='Auction Won'");
}

 

Thanks

Hi Sunfighter,

 

I was thinking of adding the update query on the page that displays the status, however if me or a member of the admin are browsing the database and the staus is set to "auction running" when in fact the auction has already ended and the user has not visited the page to update the status it could be quite misleading.

 

Is it possible to update the status automatically when the end date & time is reached?

 

Thanks

Hi

 

Not really.

 

You could set up a cron job to run every few minutes, but in this case not sure it is any better.

 

A page displaying out of date info will be confusing however you do it. Updating the database automatically somehow will not fix the out of date page that is being looked at. Doing an update to the database when things change is effectively no different to doing the update when anyone views the data (ie, just prior to getting the data to display).

 

If you want the data on display to reflect what is correct then you need to have the display update itself. Either using Javascript to calculate updates and update the display (ie, a count down). Or use Ajax to regularly query the database again and update the display.

 

Personally just do the update on EVERY page refresh, whether it is to do with that auction or not. Done this way (and with decent keying) there shouldn't be many updates per page and they shouldn't take long.

 

All the best

 

Keith

@ kickstart - Yes a cron job would get the job done, but at the cost of server time. I didn't mention it because I didn't know how often it should run (could be needed every second) nor how many actions are going on( meaning, how long the cron check would run)

 

@ perky416 - What I did assume was you would check the end time of the action (contained in the DB) with the current time to determine if the auction was open or closed.

 

If you update when anyone views the page it will be updated to the correct status. Anyone is = The Person that placed the item, You or your staff, A person just lookie lowing, Or someone coming to place a bid. They all trigger the update status and display the correct "auction running" or "auction over" That is my (1.).

 

BUT if a bidder keeps the page open to make a last time bid - you need to check that when he bids and not accept the bid if the time comparison shows the auction closed. That's why I added a second time (2.).

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.