Hello all,

Having a bit of a problem and not sure where to start with.
Maybe someone here could point me in the correct direction.
I have the following code.

$result = mysql_query("SELECT proposal.*, count(bid.proposalid) AS bids,SYSDATE(), TIME_FORMAT(TIMEDIFF(tomorrowtime, SYSDATE()), '%H hours, %i minutes') AS timeleft
FROM proposal
LEFT JOIN bid ON proposal.proposalid = bid.proposalid
WHERE proposal.username = '$username' AND proposal.time > NOW()- INTERVAL 1 DAY
GROUP BY proposal.proposalid");

This returns a set of results which I echo to the screen

If you see there I have a where NOW()- INTERVAL 1 DAY.

I want to change this to an interval of 2 days so that results for the last two days are returned

However because its a 24 auction im building whereby the auction runs for 24hrs and there is a period of 24hrs where people can accept the bids I want the timeleft row only to countdown for first 24 hours and then stop and say someting like 'end of auction' .

Anyone have an idea how to do this?

Any suggestions really appreciated!

Thanks

I am not sure i fully understand the question, but I think you may be better off taking the time calculations out of SQL and moving it into PHP. Have your table have a timestamp field, then your PHP can do the calculation when the page is rendered. If you put this calculation in a function, it'd be easy to change later if your 24hr window changes down the road to 48 hours, you could change it in 1 function, rather than in every single query. Keeping your data separate from its function will make your life easier.

Not sure thats going to answer your question, but hopefully that makes sense.

Thanks for getting back to me kylegetson

Ill rephrase my question just to ensure I'm being clear.

Ill set the query to

NOW()- INTERVAL 2 DAY

So obviously all the relevant proposals made within the last 48 hours will be returned.

I want all the proposals from the last 2 days to be returned because the auction runs for 24 hours, and then the user has a chance to accept these offers for a further 24 hours. After this 48 period the proposal should drop off the screen.

Now where the proposal is printed there is contdown row which countsdown from 24hrs. What im trying to do is after the 24hrs of the auction i want it to print 'end of auction' as the 24 hrs have expired but I still want the proposal on screen because the user can still accept the bid for another 24hrs.

Really appreciate if anyone could get suggest anything on this.

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.