I am trying to delete a row from a table using two conditions. this is my current code :
<?php
require 'database.php';
$id=0;
$od=0;
if(!empty($_GET['id_espece'])){
$id=$_REQUEST['id_espece'];
}
if(!empty($_GET['id_valor'])){
$od=$_REQUEST['id_valor'];
}
if(!empty($_POST)){
$id= $_POST['id_espece'];
$od= $_POST ['id_valor'];
$pdo=Database::connect();
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = 'DELETE FROM mode_valorisation WHERE "id_espece" = ? and "id_valor" = ? ';
$q = $pdo->prepare($sql);
$q->execute(array($id,$od));
Database::disconnect();
header("Location: page-valo.php");
}
?>
<form class="form-horizontal" action="page-supprimervalo.php" method="post" style="background: #89e29a; border-color: black; border-radius: 20px; padding: 5px;width: 500px; position: relative;right: -480px;" >
<input type="hidden" name="id_espece" value="<?php echo $id;?>"/>
<input type="hidden" name="id_valor" value="<?php echo $od;?>"/>
</form>
I Tried the solution proposed here: How to Delete a Record in php that has composite (multi-column) primary key
$sql = "DELETE FROM mode_valorisation WHERE id_espece = ? and id_valor = ? limit 1";
but it gives me the following error :
syntax error at or near "limit" LINE 1: ..._valorisation WHERE id_espece = $1 and id_valor = $2 limit 1 ^
Thank you ;