Teaky Posted August 8, 2006 Share Posted August 8, 2006 Hello there, :DI have a job, which asks me to display links on a web page, as long as their expiry date is valid. Basically I need a piece of code that…1) Grabs the Expiry date from the column of the table.2) It then compares it to today’s date.3) Only display the link if it hasn’t reached its expiry date.The way I did it was…[code]$today = date("d/m/y");SELECT link FROM table WHERE exp_date <= $today[/code]However this only compares the first values i.e. the days and it ignores everything else. :(I’ll be grateful for anyone who helps. :)Teaky Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted August 8, 2006 Share Posted August 8, 2006 Where possible it is better NOT to use php's date/time functions - those in mysql are far superior.if your database table has a field with the data type of date or datetime (or similar) it would simply be a case of using NOW() in the query.so$qry = "SELECT link FROM table WHERE exp_date >= NOW()";$qry = mysql_query($qry); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.