Jump to content

Recommended Posts

Hi guys,

 

On my auction site I have a table in my database that contains any offers made. If an offer is sent to auction an entry is made in the auctions table containing the same data as well as a status and auction end date. Im using the code below to update the auction status with "ended" when the end date has passed. Im struggling with the second query that updates the offers table.

Im trying to get it to update the status of each offer, where the auction from the auctions table has passed its end date.

 

I cant figure out how to do it. Does anybody have any ideas?

 

Thanks

 

$auction_query = mysql_query("SELECT * FROM auctions");
while ($auction_row = mysql_fetch_assoc($auction_query))
{
$date = date("Y-m-d H:i:s");
$end_date = $auction_row['end_date'];
if ($date > $end_date)
{
	$item = $auction_row['item'];
	$seller = $auction_row['seller'];
	$buyer = $auction_row['high_bidder'];
	echo $domain;
	mysql_query("UPDATE auctions SET status='ended' WHERE NOW() > end_date");
	mysql_query("UPDATE offers SET buyer_status='auction ended, you won' WHERE seller='$seller' AND buyer='$buyer'");
}

do you have any form of auction ID in the database tables?

 

You could use a NOT IN

 

ie

 

mysql_query("UPDATE offers SET buyer_status='Sorry, you did not win this auction' WHERE auctionID='$auctionID' AND buyer NOT IN ('$buyer')");

 

That would update everyone related with that auctionID who is not the "$buyer" with 'Sorrry, you did not win this auction' instead of 'auction ended, you won'.... in theory.

That exact code its self wont work unless you have some form of ID you can call on to identify, and it may not be 100% perfect as its a while since I've used "NOT IN" and thats off the top of my head lol

Im sure someone can touch it up, or confirm that I have added the NOT IN in the correct fasion

 

Hope it helps at least, or points you in the right direction.

 

Tom

 

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.