Jump to content

Simple PHP/MySQL Auction Site


ardesigns

Recommended Posts

Hi. I'd like to create a simple auction website using PHP and MySQL. Users have been assigned a certain number of points (kept in a table called "people," each person is a row and the number of points is kept in a column). The way I envision it now, this is how it would work:

There's a table called "auctions," each row is an auction. The highest bid is kept in a column, and the highest bidder's name is kept in another. When a person bids, the points are removed from their balance. When the highest bidder is outbid, the points are returned to their balance. Since the auctions will have a deadline/finishing time, my worry is that there will be a large influx of bidding at roughly the same time near the end of the auction, and the PHP/MySQL wouldn't be able to process it all at the same time. Is there any way to make sure that the script can handle multiple bids at roughly the same time?

 

Thanks!

Link to comment
Share on other sites

Is there any way to make sure that the script can handle multiple bids at roughly the same time?

 

Probably not with that kind of database design. You would be much better off having each bid stored in a new row. This way your not trying to update a single record for each bid.

Link to comment
Share on other sites

Ok. That would be fine. How would I be sure to reimburse the previous highest bidder each time there's a higher bid. E.g., what if the current bid is 100 by Bidder A. Bidder B and C bid 110 and 120 respectively at roughly the same time. The PHP would reimburse Bidder A twice, and take both Bidder B and Bidder C's money, right? Or is such a situation so unlikely as to be frivolous?

Link to comment
Share on other sites

Basically, here is how the site would work:

There's a table that holds each user's balance and a table of bids on the auction item. When a user bids on an item, the amount of money is immediately removed from their balance. When the user is outbid, they get their money back. Thus, only one user, the top bidder, has their money out at any one time. Each time there is a new bid, the PHP script will check who the previous high bidder was and return their money to their balance.

 

My question is, if two people bid at roughly the same time, won't the PHP script return the previous top bidder's money twice (once for each simultaneous bidder)? Is there any way to prevent that?

 

Thanks again (and let me know if I need to clarify further, I know this is kind of confusing and I'm not explaining it very well).

Link to comment
Share on other sites

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.