} $dbh = null; return $lijst; } public function deleteModule($id) { $sql = "delete from modules where id = :id"; $dbh = new PDO("mysql:host=localhost;dbname=cursusphp;charset=utf8", "cursusgebruiker", "cursuspwd"); $stmt = $dbh->prepare($sql); $stmt->execute(array(':id' => $id)); $dbh = null; } } $modLijst = new ModuleLijst(); if (isset($_GET["action"]) && $_GET["action"] == "verwijder") { $modLijst->deleteModule($_GET["id"]); } ?> <!DOCTYPE HTML> <html> <head> <meta charset=utf-8> <title>Modules</title> </head> <body> <h1>Modules</h1> <?php $tab = $modLijst->getLijst(); ?>
<?php require_once "module.class.php"; require_once "moduleLijst.class.php"; $ml = new ModuleLijst(); if (isset($_GET["action"]) && $_GET["action"] == "verwijder") { $ml->deleteModule($_GET["id"]); } ?> <!DOCTYPE HTML> <html> <head> <meta charset=utf-8> <title>Modules</title> </head> <body> <?php $tab = $ml->getLijst(); ?> <ul> <?php foreach ($tab as $module) { $moduleNaam = $module->getNaam(); $moduleId = $module->getId(); print "<li>" . $moduleNaam . " (<a href=\"oef91.php?action=verwijder&id=" . $moduleId . "\">Verwijderen</a>) \n\t\t\t\t\t(<a href=\"modulebewerking.php?id=" . $moduleId . "\">Bewerken</a>)</li>"; } ?> </ul> </body> </html>