la question je l'ai deja posé cette question une fois ici, j'éssaye cette fois d'être court.
quand j'essaye de vouloir supprimer un produit de ma liste il supprime toujour le premier produit
se trouvant sur ma liste et non le produit donc j'aimerai supprimé.
voici a quoi ressemble:
drucker.php
<?php
require_once __DIR__ . '/connection.php';
$id = $_POST['id'];
$img_id = $_POST['img_id'];
$type = $_POST['type'];
$user_id = $_POST['user_id'];
$sessionID = $_POST['sessionID'];
$location = $_POST['location'];
$path = $_POST['img_path'];
$time = $_POST['time'];
$check = $dbConnect->prepare('SELECT COUNT(*) FROM drucker
WHERE prod_id = :id
AND img_id = :img_id
AND img_path = :img_path
AND type = :type
AND user_id = :user_id
AND sessionID = :sessionID');
$check->bindValue(':id', $id);
$check->bindValue(':img_id', $img_id);
$check->bindValue(':img_path', $path);
$check->bindValue(':type', $type);
$check->bindValue(':user_id', $user_id);
$check->bindValue(':sessionID', $sessionID);
$check->execute();
if ((int)$check->fetchColumn() === 0) {
$stm = $dbConnect->prepare('INSERT INTO drucker (prod_id, img_id, img_path, type, user_id, sessionID, zeit) VALUES (:prod_id, :img_id, :img_path, :type, :user_id, :sessionID, :time)');
$stm->bindValue(':prod_id', $id);
$stm->bindValue(':img_id', $img_id);
$stm->bindValue(':img_path', $path);
$stm->bindValue(':type', $type);
$stm->bindValue(':user_id', $user_id);
$stm->bindValue(':sessionID', $sessionID);
$stm->bindValue(':time', $time);
$stm->execute();
}
header("Location:" . $location);?>
drucker_remove.php<?php
require_once __DIR__ . '/connection.php';
$img_id = $_POST['img_id'];
$img_path = $_POST['img_path'];
$type = $_POST['type'];
$user_id = $_POST['user_id'];
$sessionID = $_POST['sessionID'];
$data = array(); // array to pass back data
$check = $dbConnect->prepare('DELETE FROM drucker
WHERE img_id = :img_id
AND img_path = :img_path
AND type = :type
AND user_id = :user_id
AND sessionID = :sessionID');
$check->bindValue(':img_id', $img_id);
$check->bindValue(':img_path', $img_path);
$check->bindValue(':type', $type);
$check->bindValue(':user_id', $user_id);
$check->bindValue(':sessionID', $sessionID);
//$check->execute();
if ($check->execute() === true) {
$data['success'] = true;
} else {
$data['success'] = false;
}
// return all our data to an AJAX call
echo json_encode($data);
?>
a ce niveau c'est morceau de code que je vous presente a quoi ressemble ma requêteet la <form></form> donc la suppression se passe
<?php
$req = $dbConnect->query('SELECT * FROM drucker WHERE sessionID = "' . $session . '"');
$i = 1;
while ($prod = $req->fetch(PDO::FETCH_ASSOC)) { ?>
<tr>
<form class="remove" method="post" action="drucker_remove.php" name="<?php echo $prod['id'] ?>">
<input type="hidden" name="img_id" value="<?php echo $prod['img_id'] ?>">
<input type="hidden" name="type" value="<?php echo($prod['type']) ?>">
<input type="hidden" name="img_path" value="<?php echo($prod['img_path']) ?>">
<input type="hidden" name="user_id" value="<?php echo $_SESSION['user_id'] ?>">
<input type="hidden" name="sessionID" value="<?php echo $_SESSION['sessionID'] ?>">
<input type="submit" value="Löschen" name="remove_img">
</form>
</tr>
<?php } ?>
Franchemnent j'ai besoin de votre aide, je suis bloqué a ce niveauMerci bien