<?php
$action = '';
if (isset($_GET['action'])) $action = $_GET['action'];
$ID = '';
if (isset($_GET['ID'])) $ID = $_GET['ID'];
$values = '';
if (isset($_GET['values'])) $values = $_GET['values'];
$splittedvalues = explode("|",$values);
$mil = $splittedvalues[2];
$seconds = $mil / 1000;
$date = date("Y-m-d", $seconds);
switch ($action)
{
case "SelectAllAnimals":
$sql = ("SELECT * FROM Animals");
break;
case "DeleteOneAnimal":
$sql = ("DELETE FROM Animals WHERE ID = $ID");
break;
case "InsertOneAnimal":
$sql = ("INSERT INTO Animals(ID, species, name, birth_date, sex) VALUES ('$ID', '$splittedvalues[0]', '$splittedvalues[1]', '$date', '$splittedvalues[3]')");
break;
case "UpdateOneAnimal":
$sql = ("UPDATE Animals SET species= '$splittedvalues[0]', name = '$splittedvalues[1]', birth_date = '$date', sex = '$splittedvalues[3]' WHERE ID = $ID");
break;
}
?>