Dear all,
I want to search the data between the two weekdays the clients input using the mysql and php.
Assume that the weekdays indicate by the numbers given below: Sunday (0), Monday(1), Tuesday(2),...., Saturday(6).
The clients input the starting and the ending weekday, and the coresponding data which are then placed at the columns of the mysql database, that is, bweekday, eweekday, and data, respectively.
I want to search the data for today.
For example, today is Wednesday (3), which have been defined using the variable $todate=date('w'); .
$sql="select * from table where
((bweekday<='$todate' and eweekday>='$todate') ;
This statement is OK when bweekday=2(Tuesday) and eweekday=6(Saturday). It indicates that such data can be shown from Tuesday to Saturday.
However, it is not OK, when bweekday=6(Saturday) and eweekday=4(Thursday), It indicates that the data can be shown from Saturday to Thursday, and the duration in fact includes Wednesday.
Anyway, please help me to write the SQL statement such that it satisfies the above two cases.
Thanks
Simon.