我在php var中的列名中找不到查询错误

时间:2018-11-19 10:02:17

标签: php mysql

我从此查询中获得了列名:

SHOW COLUMNS FROM $table

并且我需要删除从第一个查询中获得的列中具有特定值的ROW:

$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>';
}}

0 个答案:

没有答案