<?php
require("DbModel.php");
$db_model = new DbModel;
$result_shiba=$db_model->getAll("shiba_inu");
$result_hokkaido_ken=$db_model->getAll("hokkaido_ken");
$result_husky_de_siberie=$db_model->getAll("husky_de_siberie");
$result_pomsky=$db_model->getAll("pomsky");
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Elevage des Brumes de Brocéliande</title>
<link rel="stylesheet" href="css/delee.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/ ... "></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@ ... ap.min.css"
integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"
integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous">
</script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@ ... dle.min.js"
integrity="sha384-Piv4xVNRyMGpqkS2by6br4gNJ7DXjqk09RmUpJ8jgGtD7zP9yug3goQfGII0yAns" crossorigin="anonymous">
</script>
</head>
<body>
<div class="gauche">
<div class="haut_gauche">
<h2>Supprimer la photo d'un shiba inu</h2>
<form class="del_shiba_inu" method="post">
<table class="table">
<thead>
<tr>
<th scope="col"></th>
<th scope="col">#</th>
<th scope="col">nom du chien</th>
<th scope="col">image</th>
</tr>
</thead>
<tbody>
<?php if($result_shiba): ?>
<?php foreach ($result_shiba as $key => $value):?>
<tr>
<td><input type="checkbox" id="<?=$value["id"]?>" name="<?=$value["id"]?>"></td>
<td><?=$value["id"]?></td>
<td><?=$value["nom_chien"]?></td>
<td><img src="shiba_inu/<?=$value["nom"]?>" alt="chien" height="75" width="125"></td>
</tr>
<?php endforeach;?>
<?php endif; ?>
</tbody>
</table>
<button class="btn btn-primary">Confirmer</button>
</form>
</div>
<div class="bas_gauche">
<h2>Supprimer la photo d'un hokkaido ken</h2>
<form class="del_hokkaido_ken" method="post">
<table class="table">
<thead>
<tr>
<th scope="col"></th>
<th scope="col">#</th>
<th scope="col">nom du chien</th>
<th scope="col">image</th>
</tr>
</thead>
<tbody>
<?php if($result_hokkaido_ken): ?>
<?php foreach ($result_hokkaido_ken as $key => $value):?>
<tr>
<td><input type="checkbox" id="<?=$value["id"]?>" name="<?=$value["id"]?>"></td>
<td><?=$value["id"]?></td>
<td><?=$value["nom_chien"]?></td>
<td><img src="hokkaido_ken/<?=$value["nom"]?>" alt="chien" height="75" width="125"></td>
</tr>
<?php endforeach;?>
<?php endif; ?>
</tbody>
</table>
<button class="btn btn-primary">Confirmer</button>
</form>
</div>
</div>
<div class="droite">
<div class="haut_droite">
<h2>Supprimer la photo d'un husky de siberie</h2>
<form class="del_husky_de_siberie" method="post">
<table class="table">
<thead>
<tr>
<th scope="col"></th>
<th scope="col">#</th>
<th scope="col">nom du chien</th>
<th scope="col">image</th>
</tr>
</thead>
<tbody>
<?php if($result_husky_de_siberie): ?>
<?php foreach ($result_husky_de_siberie as $key => $value):?>
<tr>
<td><input type="checkbox" id="<?=$value["id"]?>" name="<?=$value["id"]?>"></td>
<td><?=$value["id"]?></td>
<td><?=$value["nom_chien"]?></td>
<td><img src="husky_de_siberie/<?=$value["nom"]?>" alt="chien" height="75" width="125"></td>
</tr>
<?php endforeach;?>
<?php endif; ?>
</tbody>
</table>
<button class="btn btn-primary">Confirmer</button>
</form>
</div>
<div class="bas_droite">
<h2>Supprimer la photo d'un pomsky</h2>
<form class="del_pomsky" method="post">
<table class="table">
<thead>
<tr>
<th scope="col"></th>
<th scope="col">#</th>
<th scope="col">nom du chien</th>
<th scope="col">image</th>
</tr>
</thead>
<tbody>
<?php if($result_pomsky): ?>
<?php foreach ($result_pomsky as $key => $value):?>
<tr>
<td><input type="checkbox" id="<?=$value["id"]?>" name="<?=$value["id"]?>"></td>
<td><?=$value["id"]?></td>
<td><?=$value["nom_chien"]?></td>
<td><img src="pomsky/<?=$value["nom"]?>" alt="chien" height="75" width="125"></td>
</tr>
<?php endforeach;?>
<?php endif; ?>
</tbody>
</table>
<button class="btn btn-primary">Confirmer</button>
</form>
</div>
</div>
</body>
</html>
<?php
foreach ($_POST as $key => $value) {
if ($value = "on") {
$params = [":id" => $key];
var_dump($params);
$query = $DbModel->select("nom")
->from("shiba_inu")
->where("id= :id");
$result_shiba = $DbModel->query($query, $params);
var_dump($query);
$file = 'shiba_inu/'.$$result_shiba[("nom")];
if ($file) {
unlink($file); //Je suppr le fichier
}
}
}
?>
Je souhaite dans ce code supprimer des image d'un dossier.
Mon erreur vien du select mais malgré plusieurs changement de facon je n'arrive pas a le faire fonctionner !
voici mes erreurs et waring :
- Warning: Undefined variable $DbModel in C:\laragon\www\Stage\delete.php on line 156
- Fatal error: Uncaught Error: Call to a member function select() on null in C:\laragon\www\Stage\delete.php on line 156
- Error: Call to a member function select() on null in C:\laragon\www\Stage\delete.php on line 156
Si vous avez des idée et solutions n'hésitez pas !