$result=mysql_query("SELECT * FROM attendance WHERE date Between '$start_date' and '$end_date' order by date asc") or die(mysql_query);
Above mysql query is to get all data in the database between two dates selected by the user. Let say table attendance in my database as shown below
2009-07-01 3
2009-07-03 4
2009-07-04 5
2009-07-06 7
2009-07-07 6
2009-07-10 8
if the $start_date = "2009-07-01" and $end_date = "2009-07-10", it will display all the data between two selected dates
2009-07-01 3 2009-07-03 4 2009-07-04 5 2009-07-06 7 2009-07-07 6 2009-07-10 8
( I noticed that this is successful because, both dates are exist in the database).
if the $start_date = "2009-07-02" and $end_date = "2009-07-09", what i expected it to be displayed is
2009-07-03 4 2009-07-04 5 2009-07-06 7 2009-07-07 6
Unfortunately, the output never goes out like what I've expected. This is happened because both dates doesn't exist in the database. I know that something wrong with my query. It would be great if someone can help me to figure it out. Thanks in advanced!