phpSensei Posted July 15, 2007 Share Posted July 15, 2007 I have a little question... Can I use the SELECT statement, and Display all my data from a certain table depending on the date? If the date is newer then it will show that id, within the table? Any of this possible? I was thinking of this <?php $sql="SELECT * FROM table_1 ORDER BY date ASC"; $result=mysql_query($sql); $row=mysql_fetch_array($result); ?> Quote Link to comment Share on other sites More sharing options...
AndyB Posted July 15, 2007 Share Posted July 15, 2007 SELECT .... WHERE date [some operator] [some date] for example date>'2006-07-14' Quote Link to comment Share on other sites More sharing options...
phpSensei Posted July 15, 2007 Author Share Posted July 15, 2007 Edit: I know what you mean but... I dont know which function will calculate the most current date. Quote Link to comment Share on other sites More sharing options...
AndyB Posted July 15, 2007 Share Posted July 15, 2007 Exactly how you resolve it depends on what format you've used for 'date' in your database. The date() function along with the strtotime() or mktime() functions ought to be able to handle most of what you need. list($y,$m,$d) = explode("-",date("Y-m-d"));// today $month_ago = date("Y-m-d", mktime(0,0,0,$m-1,$d,$y)); Quote Link to comment Share on other sites More sharing options...
phpSensei Posted July 15, 2007 Author Share Posted July 15, 2007 Exactly how you resolve it depends on what format you've used for 'date' in your database. The date() function along with the strtotime() or mktime() functions ought to be able to handle most of what you need. list($y,$m,$d) = explode("-",date("Y-m-d"));// today $month_ago = date("Y-m-d", mktime(0,0,0,$m-1,$d,$y)); Thankyou so much, My forum is done with everything. This was the only thing left. 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.