i created an updatebids.php where given the case, if certain amount of users share the same bet, this has to update to 1 extra euro/dollar. In the picture even same user can bet the same amount :/
Here´s the query
$sql = "UPDATE {$dbPrefix}auction_bids AS b1
JOIN (
SELECT id_bid, bid_amount, customer_id, auction_id,
RANK() OVER (PARTITION BY customer_id, auction_id, bid_amount ORDER BY id_bid) AS rank
FROM {$dbPrefix}bids
) AS ranked_bids
ON b1.id_bid = ranked_bids.id_bid
SET b1.bid_amount = b1.bid_amount + 1
WHERE ranked_bids.rank > 1";
This are the logs while using the function :
/*
log: Array(6) [ "update_bids.php script started.", "Attempting database connection.. Array . <<<<<<<<<<<<<<<<<<<", "Database connection established. . >>>>>>>>>>>>>>>>>>>>", … ]
0: "update_bids.php script started."
1: "Attempting database connection.. Array . <<<<<<<<<<<<<<<<<<<"
2: "Database connection established. . >>>>>>>>>>>>>>>>>>>>"
3: "Starting bid update process..."
4: "SQL Error--------------------: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'demostore.ps_bids' doesn't exist"
5: "update_bids.php script ended."
length: 6
*/
Frontend in smarty, where inputs will be handled. Ajax is being used
// Perform the AJAX request
$.ajax({
url: '/update_bids.php',
method: 'POST',
data: {
bid_amount: bidAmount,
auction_id: auctionId,
customer_id: customerId
},
success: function(response) {
// Log the response for debugging
console.log("Auction ID:", auctionId, "Customer ID:", customerId, "Bid Amount:", bidAmount);
// Optionally, update the page or show a success message
// $('.wk-success').html('<p>Bid submitted successfully!</p>');
},
error: function(xhr, status, error) {
// Log the error for debugging, i think this one is being fired :(
console.error(xhr.responseText);
}