Jump to content

Recommended Posts

Hi there,

 

I am in the process of building a penny auction website using php / javascript. I am at the stage of developing the bidding process by which someone clicks to bid on an item, this resets a time counter and this runs over and over until someone wins when the clock strikes 00:00. My understanding is that I would be updating various database tables with the bidder information, updating the time remaining and doing this every second which would require a cronjob to be run on the server every second.

 

I wondered if anyone had real experience of working with / building one of these websites as this is slightly new to me? What I am unsure about is how complicated this constant requesting and serving information is? What are the best things to use to get / set the information.

 

I was planning on using php to update a table with the new bidder information and the date/time.

This would also update the product with the time remaining.

If a new user bids this overwrites this information and the process starts again.

 

Any information would be a massive help and much appreciated.

 

Thanks

Simon

Depending on the Database you are using and how much javascript your willing to write could depend on how you might want to go about this. If it were me, and the site was small I would stick with MySql, and furthermore, you may just want to make the script so everytime a certain bid is accessed, the bid information is updated. So, if I were to place a bid at 15:00 and the bid would run out after 1 hour, then if someone accessed that bid before then it would show the time remaining, once someone accessed the bid after it expired at 16:00 then it would show the bid has completed and not allow any more bids, thus showing a winner. But What you do also depends on what happens after the time has expired and someone won. So....more details is always great.

There's no need to continually update a 'time left' column; you can infer the time remaining based on when the auction ends. A simple JS countdown timer can tick down in real time. Periodically you can poll the server for bid updates using an XHR request. Or better yet, use WebSockets to keep a connection open while data is continually fed back from the server. WebSockets aren't fully supported yet, so you could use "long polling" instead. Personally I would adopt WebSockets now though, and fall-back to periodic requests for browsers that don't support them. Long polling is a bit hacky.

 

As for the PHP side, whenever someone creates a bid just insert it into a 'bid' table. Don't delete their bids after an auction has ended or when someone else bids though, that data will provide nice statistics for you and allow users to look through their own bid history. With the right indexes you won't need to worry about performance, even if the table grows very large.

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.