Jump to content


A bidding system with PHP and MySQL

  • Please log in to reply
3 replies to this topic

#1 phil321

  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 18 July 2006 - 12:36 PM

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!

#2 SammyP

  • Members
  • PipPipPip
  • Advanced Member
  • 58 posts
  • LocationLondon

Posted 18 July 2006 - 01:21 PM

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.


If this has solved your problem, a quick 'Thanks' is appreciated, but marking the thread as 'Solved' is better - it saves a lot of time.


#3 Ninjakreborn

  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 18 July 2006 - 03:01 PM

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.


Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.

#4 redarrow

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

Posted 18 July 2006 - 04:53 PM

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!";


Wish i new all about php DAM i will have to learn

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users