I got the column name from this query:
SHOW COLUMNS FROM $table
and I need to delete a ROW with a specific value in a column that I got from the first query:
$con = mysqli_connect("localhost","root","password","database");
if(isset($_POST['sup'])){
if(mysqli_connect_error()){
echo "Failed connection";exit;
}
$table=$_POST['table_sup'];
$requet = "SHOW COLUMNS FROM $table";
$result = mysqli_query($con,$requet);
if(!$result){
echo "requete incorrecte";
}
$j=0;
while($row=mysqli_fetch_array($result)){
$monChamps=$row["Field"];
$row1[$j]=$monChamps."<br>";
$j++;
}
$champ1=$_POST['champ_sup'];
$id=$row1[0];
$requet1="DELETE FROM $table WHERE $id='$champ1'";
if(mysqli_query($con,$requet1)){
echo '<script language="javascript">';
echo 'alert("supprimer")';
echo '</script>';
}}
` on the end of it (`$row1[$j]=$monChamps."
"; $id=$row1[0];`), maybe that is causing the query to not match anything? – Nick Nov 20 '18 at 22:19