PDO::ERRMODE_EXCEPTION )); } catch (Exception $e) { die("Error : ".$e->getMessage()); } $_SESSION['error_msg'] = ""; if (isset($_POST['submit'])) { if (isset($_POST['species']) and $_POST['species'] != "") { $_SESSION['query']['species'] = $_POST['species']; } if (isset($_POST['subspecies']) and $_POST['subspecies'] != "") { $_SESSION['query']['subspecies'] = $_POST['subspecies']; } if (isset($_POST['recordist']) and $_POST['recordist'] != "") { $_SESSION['query']['recordist'] = $_POST['recordist']; } if (isset($_POST['date-after']) and $_POST['date-after'] != "") { $_SESSION['query']['date-after'] = $_POST['date-after']; } if (isset($_POST['date-before']) and $_POST['date-before'] != "") { $_SESSION['query']['date-before'] = $_POST['date-before']; } if (isset($_POST['keywords']) and $_POST['keywords'] != "") { $_SESSION['query']['keywords'] = explode(',', $_POST['keywords']); } } else { $_SESSION['error_msg'] .= "You did not submit the search form. \n"; } if ($_SESSION['error_msg'] == "") { if (isset($_SESSION['query'])) { $sql = 'SELECT * FROM `records` WHERE '; $and = False; if (isset($_SESSION['query']['species']) and $_SESSION['query']['species'] != "") { if ($and) { $sql .= " AND "; } $sql .= ' species LIKE "%'.$_SESSION['query']['species'].'%"'; $and = True; } if (isset($_SESSION['query']['subspecies']) and $_SESSION['query']['subspecies'] != "") { if ($and) { $sql .= " AND "; } $sql .= ' subspecies LIKE "%'.$_SESSION['query']['subspecies'].'%"'; $and = True; } if (isset($_SESSION['query']['recordist']) and $_SESSION['query']['recordist'] != "") { if ($and) { $sql .= " AND "; } $sql .= ' recordist_name LIKE "%'.$_SESSION['query']['recordist'].'%"'; $and = True; } if (isset($_SESSION['query']['date-after']) and $_SESSION['query']['date-after'] != "") { if ($and) { $sql .= " AND "; } $sql .= ' date>='.$_SESSION['query']['date-after']; $and = True; } if (isset($_SESSION['query']['date-before']) and $_SESSION['query']['date-before'] != "") { $sql .= ' date<='.$_SESSION['query']['date-before']; } if (isset($_SESSION['query']['keywords'])) { $sql .= " remarks "; $and = False; foreach ($_SESSION['query']['keywords'] as $keyword) { if ($keyword != ""){ if ($and) { $sql .= " AND "; } $sql .= " LIKE '%$keyword%' "; } $and = True; } } } else { $_SESSION['error_msg'] .= _("You did not enter any query.").'\n'; header("Location: /explore/search"); } } else { header("Location: /explore/search"); } ?> <?=_('Explore')?> | Chiro - Canto

prepare($sql); $req->execute(); $result = $req->fetchAll(); // print_r($sql); if (empty($result)) { echo _("No result for this query, please try again.").'\n'; } else { ?>