Jump to content


This topic is now archived and is closed to further replies.


A bidding system with PHP and MySQL

Recommended Posts

Hello there,

I have a number of products which I would like to auction off on my site. I would like to get it so that when a customer clicks on a product, they are given the oppurtunity to make a bid for it, right up until the last minute of the auction. I have some PHP and MySQL experience, but is it appropriate to design a script that retrieves the current high bid from a database and allows the customer to enter their email address and a new bid? The script then simply checks if the bid is higher, and if so, sets the new high bid and email address of the new high bidder. What about multiple people trying to bid at the same time - would it be stable (for example, in the last few minutes of the auction)?

Or is this something I should rather find a pre-made script to do?

Thanks for your time and help!

Share this post

Link to post
Share on other sites
So long as the condition is part of the update query that the new bid must be greater than the current one, then you should be fine. When MySQL goes to update the data it should briefly lock the data. All db systems do this. So then it will very quickly check that the bid is higher and update the bid and email fields. If it turns out that another bid has come in first then it will be apparent either in the fact that the query didn't do what was intended, and so the current bid is now higher what the user had attempted to enter, or you can check mysql_affected_rows to see if it worked.


Share this post

Link to post
Share on other sites
It wouldn't be that difficult to build that system, so it's worth a shot, you'll get better results with that, by hand, than using pre-made scripts, because you can define your own featuers.

Share this post

Link to post
Share on other sites
example only




$current_amount="200"; // from the database

$new_amount="400"; // the user input new bid from a form under new_amount.

if($new_amount > $current_amount) {

$query="update bids set $current_amonut where id='$id'":


}else if ($new_amount < $current_amount) {

echo " sorry your bid was lower then the current bid please try agin"


echo "Thank you  $user your bid is at the top!";



Share this post

Link to post
Share on other sites


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.