Hi,
I Want to switch my query depending if a get variable exists. If it exists then the query checks for dates matching the get data.
The query below doesnt seem to bring back any results or errors. The query also uses joins
How should it be?PHP Code:if(isset($_GET['sbd'])) {
$eventdate = ''.$_GET['yearnow'].'-'.$_GET['monthnow'].'-'.$_GET['day'].'';
$where = "WHERE e.eventdate = $eventdate";
}
elseif(isset($_GET['userid'])) {
$where = "WHERE u.userid = ".$_GET['userid']."";
}
elseif((!$location == '') && (!$type =='')) {
$where = "WHERE u.location = '$location' && e.type = $type";
}
elseif((!$location == '')) {
$where = "WHERE u.location = '$location'";
}
elseif(!$type == '') {
$where = "WHERE e.type = $type";
}
elseif($location == '') {
$where = "";
}
$sql = mysql_query("SELECT e.eventid, e.type, e.heading, DATE_FORMAT(e.eventdate, '%Y-%m-%d'), e.description, e.imagename, u.userid, u.companyname
FROM events as e
LEFT JOIN users as u ON e.userid = u.userid
".$where." && u.username != 'admin'
ORDER BY e.eventdate ASC");
Thanks









Bookmarks