murdo Posted December 17, 2007 Share Posted December 17, 2007 ok i have a date output from a simple SQL database.... If "year" part of the date doesn't match, I want a standard message. if it does match, I want to echo the full date... here is what I am using: <?php $year=date("Y"); if ($year=="2008") echo "N/A"; else echo "$date"; ?> All my dates in the database are 2008.. however on the page, I am getting the $date echo instead of "N/A" am I doing something wrong?? Quote Link to comment Share on other sites More sharing options...
lemmin Posted December 17, 2007 Share Posted December 17, 2007 date() gets the current date, which is 2007. You don't have anything from your database query in this conditional statement. Quote Link to comment Share on other sites More sharing options...
murdo Posted December 17, 2007 Author Share Posted December 17, 2007 ahhhhh i see where you are coming from! duh!! So I use this: $query="SELECT *, DATE_FORMAT(date,'%D %M %Y') as date2 FROM datestable and $date=mysql_result($result,$i,"date2"); so to show the date from the databse in my page, i do <? echo $date; ?> but how do I condition that so if the year isn't 2008 it doesn't show?? Quote Link to comment Share on other sites More sharing options...
murdo Posted December 17, 2007 Author Share Posted December 17, 2007 never mind... problem solved... 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.