phil321 Posted July 18, 2006 Share Posted July 18, 2006 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! Quote Link to comment https://forums.phpfreaks.com/topic/14929-a-bidding-system-with-php-and-mysql/ Share on other sites More sharing options...
SammyP Posted July 18, 2006 Share Posted July 18, 2006 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.Sam. Quote Link to comment https://forums.phpfreaks.com/topic/14929-a-bidding-system-with-php-and-mysql/#findComment-59880 Share on other sites More sharing options...
Ninjakreborn Posted July 18, 2006 Share Posted July 18, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/14929-a-bidding-system-with-php-and-mysql/#findComment-59913 Share on other sites More sharing options...
redarrow Posted July 18, 2006 Share Posted July 18, 2006 example only<?$new_amount=($_POST['new_amount']);$current_amount=($_POST['curent_amount']);$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'":$result=mysql_query($query);}else if ($new_amount < $current_amount) {echo " sorry your bid was lower then the current bid please try agin"}else{echo "Thank you $user your bid is at the top!";}?> Quote Link to comment https://forums.phpfreaks.com/topic/14929-a-bidding-system-with-php-and-mysql/#findComment-59970 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.