There are many ways to sort by date. I use something like this SELECT * FROM newsitems WHERE newsdate=(whatever date you want);
For selecting records for the current date I use php's date function to get the current date in the right format. $current_date = date("Ymd"); SELECT * FROM newsitems WHERE newsdate=$current_date; I also use php's mktime function to create past and future days formated for mysql date field. $yesterday = mktime (0,0,0,date("m") ,date("d")-1,date("Y")); $date_yesterday = date("Ymd",$yesterday); SELECT * FROM newsitems WHERE newsdate=$date_yesterday; Some of what you've written leads me to believe you might want to use ORDER BY in your sql. If you want to pull all the newsitems from the db and then order(not sort) them by date date (descending) you need something like this SELECT * FROM newsitems ORDER BY newsdate DESC; Hope this helps, Mike Kirk Babb wrote: > I have a db table which holds news in the following manner: > ID (auto-increment), newsdate (DATE), newstitle, and newstext > > I have been displaying them by ID, and would like instead to sort them by > date (descending). Since I'm using Flash I have been doing > mysql_fetch_array for each ID query and then separating the fields out for > placement in the dynamic text fields (has to be done for formatting), like > so: > > $news_details1 = mysql_query("SELECT * FROM newsitems where ID='1'"); > $headlines1 = mysql_fetch_array($news_details1); > ....then populate the fields with echo "&newstitle1=" . > $headlines1["newstitle"] etc > > Can I do this in a better way (more efficient)? and sort by date? I > haven't done any sorting before, and if it pulls all the data into an array > wouldn't that really be a 2D array? How do I handle that? > > Thanks for any help or suggestions, > > Kirk > > > > -- Mike -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php