If statement in MySQL query with PHP
- by user1104854
Is it possible to use an if statement in a MySQL query in a similar what I'm showing? I want to grab some information for upcoming events(not ones with previous dates).
ini_set('date.timezone', 'America/New_York');
$timestamp = date('m/d/Y');
$sql = "select eventID,eventTitle,eventDate from events where eventLocationID = $locationID ORDER BY eventDate DESC IF(eventDate > $timestamp) ";
I really want to avoid doing post-query if statements that will only print if it's after today's date because I run it through a pagination function, and I'd really prefer to avoid tinkering with that.