basic date comparsion for expiration checking [closed]

纵然是瞬间 提交于 2019-11-29 17:59:32

In your while loop, you iterate over all entries in the supplier_stats table. For every iteration, you output "<p>Insurance Expires ! .... You probably do not want to do that. Edit your query to only select the entries that will expire within your range.

Example:

SELECT * FROM supplier_stats WHERE insurance_date >= yourDateToCompareTo

Depending on how you did set up your Database, insurance_date may be of 'MySQL Type DATE or String or even Integer. Depending on that, you have to make the Comparsion to check if the date is close to your expiration range.

After your loop (closed by }) you still use the $info in your if ($info['insurance_date'] which will only use the LAST entry in your table.

This is however a very, very basic Question and i'd advise you to read up on some very basic beginners tutorials which can be found easily using an internet search engine.

I'm guessing $info['insurance_date'] is a datetime string in the format YYYY-mm-dd HH:ii:ss, right?

If this is the case, you will need to run it through strtotime before comparing it to a numeric time (time()+$date_diff)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!