|
|
Sometimes you need to present different data to different groups
of users. Let's say you run a classified ads board and needs to
display last seven days data to regular users while admin should be
able to see all adds.
For this purpose use Before SQL
Query event of the List page.
Note: Change the values listed in
red to match your specific needs.
1. For MS SQL Server database:
if ($_SESSION["UserID"]!="admin")
$strWhereClause = whereAdd($strWhereClause, "DATEDIFF(day,GETDATE(),DateColumn) <= 7");
|
2. For MySQL database:
if ($_SESSION["UserID"]!="admin")
$strWhereClause = whereAdd($strWhereClause, "DATE_SUB(CURDATE(),INTERVAL 7 DAY) <= DateColumn");
|
3. For MS Access database:
if ($_SESSION["UserID"]!="admin")
$strWhereClause = whereAdd($strWhereClause, "DATEDIFF('d',Now(),DateColumn) <= 7");
|
whereAdd() function
adds new AND condition to
WHERE clause. More info on Data Access Layer
functions.
|