entfernen ein Produkt aus der Liste

Henrigo007

Mitglied
Hallo Leute,
ich hatte schon mal die Frage gestellt, diesmal muss ich mich anders fomulieren.
wenn ich Produkte auf meiner Liste habe und versuche ich zu entfernen,
leider werden nicht die richtige produkten entfernen, es wird immer der erste Produkt auf meiner
liste entfernt, egal ob ich produkt in der Mitte oder am ende meiner Liste entfernen möchte.

Hier sind die scripte
drucker.php
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);?>

damit löschen ich die Produkte aus meine Liste
drucker_remove.php
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);
?>

hier ist ein Stückcode, genau die Stelle, wo die Produkte aus der liste entfernen werden

PHP:
<?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 } ?>

so sieht meine Tabelle aus, die ich auch drucker genannt habe

CREATE TABLE IF NOT EXISTS `drucker` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`prod_id` int(11) NOT NULL,
`img_id` int(11) NOT NULL,
`img_path` varchar(256) NOT NULL,
`type` varchar(256) NOT NULL,
`user_id` int(11) NOT NULL,
`sessionID` varchar(256) NOT NULL,
`zeit` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ;


bitte ich brauche drigend ihre hilfe, ich hänge schon länge an der Stelle.
Dank im Voraus
 
Zurück