coolphpdude Posted June 13, 2008 Share Posted June 13, 2008 hi there, I need help with formatting a search query. I have a database of memo's for a user, each memo has an expiry date, i only want to display the memo's to the user that have not yet expired. so for example I have a memo that is no use past the 20th of june so i set the expirary date in the database to 2008-06-20. This memo will be shown until and including the the 20th of june. Come the 21st of June that memo will no longer be displayed. how do i include that in my search query??? so far ive got this, $memo_result = mysql_query("SELECT * FROM memos WHERE username='$user'", $db); This works and all memos are displayed but i need to add something along the lines of:- $memo_result = mysql_query("SELECT * FROM memos WHERE username='$user' AND curdate <= 'expirary_date'", $db); Can anyone help? Link to comment https://forums.phpfreaks.com/topic/110046-date/ Share on other sites More sharing options...
RMcLeod Posted June 13, 2008 Share Posted June 13, 2008 Something along the lines of $today = date('Y-m-d'); $memo_query = "SELECT * FROM memos WHERE username='$user' AND expiry_date >= '$today'"; $memo_result = mysql_query($memo_query, $db) or die (mysql_error()); Link to comment https://forums.phpfreaks.com/topic/110046-date/#findComment-564668 Share on other sites More sharing options...
coolphpdude Posted June 13, 2008 Author Share Posted June 13, 2008 thanks alot! that works a treat!!! Link to comment https://forums.phpfreaks.com/topic/110046-date/#findComment-564678 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.