52 lines
1.3 KiB
PHP
Executable File
52 lines
1.3 KiB
PHP
Executable File
<?php
|
|
session_start();
|
|
ini_set('display_errors', 1);
|
|
ini_set('display_startup_errors', 1);
|
|
error_reporting(E_ALL);
|
|
$root = realpath($_SERVER["DOCUMENT_ROOT"]);
|
|
require "$root/database/credentials.php";
|
|
// Connect the database
|
|
try {
|
|
$db = new PDO("mysql:host=$host;dbname=$database;charset=utf8",
|
|
$user,
|
|
$password,
|
|
array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
|
|
));
|
|
} catch (Exception $e) {
|
|
die("Error : ".$e->getMessage());
|
|
}
|
|
$q = $_REQUEST['q'];
|
|
$req = $db->prepare("SELECT taxon_species FROM `taxa`
|
|
WHERE (id LIKE '%$q%'
|
|
OR lower(taxon_phylum) LIKE '%$q%'
|
|
OR lower(taxon_kingdom) LIKE '%$q%'
|
|
OR lower(taxon_class) LIKE '%$q%'
|
|
OR lower(taxon_order) LIKE '%$q%'
|
|
OR lower(taxon_family) LIKE '%$q%'
|
|
OR lower(taxon_subfamily) LIKE '%$q%'
|
|
OR lower(taxon_tribu) LIKE '%$q%'
|
|
OR lower(taxon_genus) LIKE '%$q%'
|
|
OR lower(taxon_species) LIKE '%$q%')");
|
|
$req->execute();
|
|
$result = $req->fetchAll();
|
|
// print_r($result);
|
|
$species = array();
|
|
foreach ($result as $row) {
|
|
$species[] = $row['taxon_species'];
|
|
}
|
|
// print_r($species);
|
|
|
|
// Output "no suggestion" if no hint was found or output correct values
|
|
?>
|
|
<select name="species" id="species">
|
|
<?php
|
|
echo "Hello";
|
|
foreach ($species as $sp) {
|
|
?>
|
|
<option value="<?=$sp?>"><?=$sp?></option>
|
|
<?php
|
|
}
|
|
?>
|
|
</select>
|
|
<?
|