I'd say I'm a newbie to PHP and MySQL, and am looking for a solution to this problem!
I have to create an auction site for my coursework, and I'm trying to make auctions that expire.. well.. expire. I have 'Expires' and 'Starts' stored in my SQL table, obviously.
I want to make sure on the home page, only auctions that have not expired are displayed - as you can see, this, at the moment is not the case.
To add the 'Expires' value to a product, I used this MySQL code:
and here is my homepage script:
any help to how to tackle this would be appreciated, I'm having a real hard time!
I have to create an auction site for my coursework, and I'm trying to make auctions that expire.. well.. expire. I have 'Expires' and 'Starts' stored in my SQL table, obviously.
I want to make sure on the home page, only auctions that have not expired are displayed - as you can see, this, at the moment is not the case.
To add the 'Expires' value to a product, I used this MySQL code:
// add start date
$insertstart = "UPDATE smith_auctions SET Starts = NOW() WHERE AuctionTitle = '".$test."'";
$result2 = mysql_query($insertstart) or die(mysql_error());
// add expiry date
$insertexpiry = "UPDATE smith_auctions SET Expires = NOW() +INTERVAL 7 DAY WHERE AuctionTitle = '".$test."'";
$result3 = mysql_query($insertexpiry) or die(mysql_error());
and here is my homepage script:
while($row = mysql_fetch_array($result2,MYSQL_ASSOC))
{
$op1 = (string) $row['Expires'];
$op2 = (string) date("Y M J H:i:s");
echo "<tr><td><a href='product.php?id=$row[AuctionID]'>$row[AuctionTitle]</a></td><td>£".$row[CurrentPrice]."</td><td>$row[NumberBids] bids</td><td>Ending: ".$row[Expires]."</td>";
echo "<td><a href='product.php?id=$row[AuctionID]'>Bid</a> or </td>";
echo "<td>";
$bin = $row['BIN_Price'];
if ($row['BIN_Price'] > 0 )
{ echo "<a href='product.php?id=$row[AuctionID]'>Buy Now!</a></td></tr>"; }
}
any help to how to tackle this would be appreciated, I'm having a real hard time!