<?php require_once 'marca.php'; require_once 'colecaodemarcasbdr.php'; require_once 'pdoinstance.php'; $pdoi = new PDOInstance(); $pdo = $pdoi->getInstance(); $marcaBDR = new ColecaoDeMarcasBDR($pdo); if ($_GET['id']) { $id = htmlspecialchars(trim($_GET['id'])); $marcaBDR->remove($id); header('Location: marca-lista.php'); } else { die('Problema em marca-remover.'); }
<?php require_once 'pdoinstance.php'; require_once 'colecaodemarcasbdr.php'; $pdoi = new PDOInstance(); $pdo = $pdoi->getInstance(); $marcaBDR = new ColecaoDeMarcasBDR($pdo); ?> <html> <head></head> <body> <table border='1'> <tr> <th>Nome</th> <th>Alterar</th> <th>Remover</th> </tr> <?php foreach ($marcaBDR->todos() as $m) { echo '<tr>' . '<td>' . $m->getNome() . '</td>' . '<td><a href="marca-form.php?id=' . $m->getId() . '">Alterar</a></td>' . '<td><a href="marca-remover.php?id=' . $m->getId() . '">Remover</a></td>' . '</tr>';
<?php require_once 'marca.php'; require_once 'colecaodemarcasbdr.php'; require_once 'pdoinstance.php'; $pdoi = new PDOInstance(); $pdo = $pdoi->getInstance(); $marcaBDR = new ColecaoDeMarcasBDR($pdo); if (isset($_GET['id'])) { $id = htmlspecialchars(trim($_GET['id'])); $marca = $marcaBDR->comId($id); } else { $marca = new Marca(); } if (isset($_POST['enviar'])) { if (isset($_POST['id']) and isset($_POST['nome'])) { $id = htmlspecialchars(trim($_POST['id'])); $nome = htmlspecialchars(trim($_POST['nome'])); $marca = new Marca($id, $nome); $marcaBDR->add($marca); header('Location: marca-lista.php'); } } ?> <html> <head></head>