php - How to get the closest row to the current date in my table? -
i pull out table database current day lands when user visits page.
table sample:
---+----------+----------- id | | ---+----------+----------- 1 |2015-07-01|2015-07-14 ---+----------+----------- 2 |2015-07-15|2015-07-31 ---+----------+----------- 3 |2015-08-01|2015-08-20
output:
if date 2015-07-10
output should id 1
if date 2015-08-02
output should id 3
if understand question right, want select row today's date between "from" , "to"?
if that's case should this:
select id your_table_name curdate() >= `from` , curdate() <= `to`
or if like:
select id your_table_name curdate() between `from` , `to`
both queries return 1 or many rows today's date in between "from" , "to".
Comments
Post a Comment