Commit f4fd7073 authored by Gabriel Moreau's avatar Gabriel Moreau
Browse files

Add function caterory_new and remove INSERT in code

parent 36d9db39
......@@ -30,11 +30,9 @@ if (!empty($erreur)) {
exit();
}
$sql = 'INSERT INTO categorie (nom) VALUE (?);';
$stmt = $pdo->prepare($sql);
$stmt->execute(array($categorie));
$id_category = set_category_new($pdo, $categorie);
echo '<br />ajout de '.$categorie.' valid&eacute;e';
echo '<br />Ajout de la cat&eacute;gorie '.$categorie.' valid&eacute;e';
echo '<br /><br /><a href="equipment-list.php">Suite</a><br /><br />';
?>
......
......@@ -151,6 +151,15 @@ function check_category_by_name($pdo, $name) {
// ---------------------------------------------------------------------
function set_category_new($pdo, $name) {
$sql = 'INSERT INTO categorie (nom) VALUE (?);';
$stmt = $pdo->prepare($sql);
$stmt->execute(array($name));
return $pdo->lastInsertId();
}
// ---------------------------------------------------------------------
function get_loan_all_by_id_equipment($pdo, $id_equipment) {
// recupere l'appareil via l'id qui est mis dans un champs texte (nom) !
$sql = 'SELECT * FROM pret WHERE nom = ?;';
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment