You have several ways to handle this problem. Most of them are based in
your PHP (of which I am not an expert) however I can get you  all of the
articles for the last 5 days in a single query:

select format(datefield, '%d.%m.%Y.'), newsfield
from newstable
where datefield >= (DATE_FORMAT(NOW() - INTERVAL 5 DAY, '%Y-%m-%d'))

The math arithmetic is one way of getting everything from midnight of a day
and not just from *exactly* 5 days ago.  (If you ran the query at 5 in the
afternoon on the 10th, the INTERVAL 5 DAY math would make the oldest
article from 5PM on the 5th.)

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine




                                                                                       
                                                          
                      "T. H. Grejc"                                                    
                                                          
                      <[EMAIL PROTECTED]        To:       [EMAIL PROTECTED]            
                                                       
                      ru>                      cc:                                     
                                                          
                      Sent by: news            Fax to:                                 
                                                          
                      <[EMAIL PROTECTED]        Subject:  Select Dates and then select 
news with that dates                                       
                      rg>                                                              
                                                          
                                                                                       
                                                          
                                                                                       
                                                          
                      05/17/2004 03:16                                                 
                                                          
                      PM                                                               
                                                          
                                                                                       
                                                          
                                                                                       
                                                          




Here is what I'm trying to achieve:

*10.04.2004.*- news 1
- news 2
- news 3
*14.04.2004.*- news 4
*15.04.2004.*- news 5

What method will be the best. Do I have to use two queries. One to
select (5) last dates, and then loop throug that results and select news.

select dates
while (dates)
select news where dates
endwhile

Im shure that there is the easier way.

I'm using PHP/MySQL (3.23.56)

TNX


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]







-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to