0

I'm working on an auction script for a client. This portion of the script pulls all the open auctions from the database and allows bidding, but they only want bidding on auction with 30 seconds left until it ends.

$query = "select * from DSI_auctions
         WHERE closed='0' AND
         suspended='0' AND ";
         $query .= "starts<=".$NOW." 
         order by ends LIMIT ".$SETTINGS['endingsoonnumber'];
$result = mysql_query($query);


$num_auction = mysql_num_rows($result);
    //echo $num_auction;

I've thought of having the script change the current time and ending time to epoch and determinig the difference but if I do that it will only return 1 row even if I add something like:

$AE = 0;
while $AE < 10 {


}
$AE++

I am stupmed.

4
Contributors
6
Replies
7
Views
5 Years
Discussion Span
Last Post by pritaeas
0

Yeah, sorry thats my bad... But the query still only pulls auctions that have started

$query .= "starts<=".$NOW."

. I need it to pull auctions that end in 30 secs or less...

0
//set timezone - ensure DB TZ same as script TZ??
$now = date('Y-m-d H:i:s);
$end = date('Y-m-d H:i:s, time() + 31);
//I'm assuming your datetimes are stored in yyyy-mm-dd hh:mm:ss format
$query = "select * from DSI_auctions WHERE closed='0' AND suspended='0' AND starts <= '$now' AND ends < '$ends' ORDER BY ends LIMIT ".$SETTINGS['endingsoonnumber'];
$result = mysql_query($query);

Something like that?

You can have a javascript timer then to countdown to the end of each one (no need to have multiple timers - just one to decrement each value - disable on 0)

Edited by diafol: n/a

0

Thank you so much, I think that's it and I can NOT believe I didn't think of that... My brain hurts.... it's been a long week for sure....

I'll try that when I get back in.

0

This is what I used. Thank you so much for the insight.

$endsoon = ($NOW  + 55);
$query = "select * from DSI_auctions
         WHERE closed='0' AND
         suspended='0' AND ";
         $query .= "starts<=".$NOW." AND ";
		 $query .= "ends<".$endsoon."
         order by ends LIMIT ".$SETTINGS['endingsoonnumber'];
$result = mysql_query($query);

I increased it to 55 as this cron runs every minute and loops 60 times grabbing other variables. Having it at 31 caused a delay and would not allow bidding at 30 secs.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.