一段时间后隐藏物品[PHP / MySQL]

I want that items hide after the time expired, only today and future items would be shown.

I have code like that now but it doesn't work:

$result = mysql_query("SELECT * FROM table WHERE closing_date >= CURRENT_DATE()");
$numrow = mysql_num_rows($result);

In the MYSQL I have closing_date in that format:

sample: 2014-07-03 20:11:26

So now if time expire item would not be shown on page.

The code don't want work I had tryed many solutions but none didn't work :(

Timeformat must stay same as it is.

Thanks for help!

Replace CURRENT_DATE() with NOW()

You need to set up cronjob that will run once a day or every few minutes that will run a script which will hide those items.

Your script should have this query:

UPDATE table SET hide_column = 1 WHERE closing_date < CURRENT_DATE()

If you dont want to hide anything and just grab data from today & after today you need to know what is the type of your closing_date column. If its datetime use NOW() to compare:

SELECT * FROM table WHERE closing_date >= NOW()

CURRENT_DATE() just returns the date without time. that's why your code doesn't work as you want it to. you need to add the time, for example like this:

$result = mysql_query("SELECT * FROM table WHERE closing_date >= CONCAT(CURDATE(), ' ', CURTIME())");
$numrow = mysql_num_rows($result);

CURRENTDATE() is in the format 1997-12-15. If your format is 2014-07-03 20:11:26, you could do something like this.

$currentDate = date(Y-m-d G:i:s);
$result = mysql_query("SELECT * FROM table WHERE closing_date >=" . $currentDate);
$numrow = mysql_num_rows($result);