Database select script
$querySQL = "SELECT ";
$parameters = [$datum];
switch ($table) {
    case "quote":
        $querySQL .= "content, author FROM quote WHERE datum = ?";
        break;
    case "birthday":
        $querySQL .= "date, name FROM birthday WHERE datum = ?";
        break;
    case "facts":
        $querySQL .= "content FROM facts WHERE datum = ? AND category = ?";
        $parameters[] = $_POST['categorie'];
        break;
    case "lifehacks":
        $querySQL .= "content FROM lifehacks WHERE datum = ?";
        break;
}
$querySQL .= " LIMIT 10";
$stmt = $connection-&gt;prepare($querySQL);
$stmt-&gt;execute($parameter);


Perhaps you're looking for something such as this. You had lots of repetition in your code, and so I basically applied the DRY rules to your code. It could still use a lot of work and I'm sure there's other approaches, but this might help you kickstart the process!

Another way to possibly help improve your code would be to separate the logic, database access, and your echos. You've probably heard of frameworks and such, and you might want to start looking into your options. It will keep your code separated, and while maybe not shorter, it will be much neater!