[SELECT * FROM ost_ticket WHERE staff_id = <?=$rowtotalstaff['staff_id']?> AND (14 >= TIMESTAMPDIFF(DAY,created,NOW()) AND 7 < TIMESTAMPDIFF(DAY,created,NOW())) AND status = "open"]

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '<?=$rowtotalstaff['staff_id']?> AND (14 >= TIMESTAMPDIFF(DAY,created,NOW()) AND ' at line 1