jwdbjbebefin jwdbjbebefin - 1 year ago 93
PHP Question

show only results after todays date

I have a database with dates and information associated with it. The problem I am having is that I am trying to get it to show only results that match after a certain date.

The way I have tried is using MySQL, if it is possible I would like an answer in mysqli which is more protected.

$query=("SELECT * FROM availability WHERE day >= date('Y-m-d')");
<td><?php echo $row['day'];?></td>
<td><?php echo $row['hour'];?></td>
<td><?php echo $row['booked'];?></td>

Answer Source

You can use CURDATE() MySQL function to get and compare the current date with column.

Use it like this,

$query=("SELECT * FROM availability WHERE day >= CURDATE()");

As @tadman suggested

Do not use the mysql_query interface.
It’s so awful and dangerous that it was removed in PHP 7. Instead, the MySQLi or PDO_MySQL extension should be used.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download