Php 如果结果未在数据库中列出,则删除行(数组循环)

Php 如果结果未在数据库中列出,则删除行(数组循环),php,sql,Php,Sql,情况:问题列表将从数据库中读取并显示在表中。我可以添加新行或删除我想要的行。将提交的数据将使用数组存储。更新和插入的工作原理如下所示 问题:如果用户删除表中的某些行,我如何删除数据库中的这些数据 抱歉语法/英语不好。谢谢你的帮助 Html代码: <table class="msgBox" id="simulator2"> <tr> <th></th> <th class="msgSubject">QUESTION<

情况:问题列表将从数据库中读取并显示在表中。我可以添加新行或删除我想要的行。将提交的数据将使用数组存储。更新和插入的工作原理如下所示

问题:如果用户删除表中的某些行,我如何删除数据库中的这些数据

抱歉语法/英语不好。谢谢你的帮助

Html代码:

<table class="msgBox" id="simulator2">
<tr>
    <th></th>
    <th class="msgSubject">QUESTION</th>
</tr>
<?php
    $qry="SELECT ques_item, ques_id FROM log_question WHERE eva_id = '$action'";
    $result=mysqli_query($con, $qry);
    $count=mysqli_num_rows($result);
    $i=1;
    while($rows=mysqli_fetch_array($result)){
        $eQuesID = $rows['ques_id'];
        $eQues = $rows['ques_item'];
?>
<tr class="table-row">
    <td><input type="checkbox" name="chk" /></td>
    <td class="dataBox"><input type="text" name="eQues[]" value="<?php echo $eQues; ?>" /><input type="hidden" name="eQuesID[]" value="<?php echo $eQuesID; ?>" /></td>
</tr>
<?php $i++; 
    } $tempCount = $i-1;
?>
</table>
<br />
<center>
    <input type="button" value="Add Row" onclick="addRow('simulator2')" />
    &nbsp;&nbsp;&nbsp;
    <input type="button" value="Delete Row" onclick="deleteRow('simulator2')" />
</center>

问题:

您需要使用ajax来删除行。没有比手动@RuchishParikh更好的起点了除了ajax还有其他解决方案吗?我不知道如何使用ajax(@Fred ii-我知道sql delete是如何工作的=。=”问题是,如果用户删除表上的行(html代码),如何删除数组中未包含的其余选定数据。您需要使用ajax来删除行。没有比手动@RuchishParikh更好的起点了,除了ajax还有其他解决方案吗?我不知道如何使用ajax:(@Fred ii-我知道sql delete的工作原理=。=“问题是,如果用户删除表中的行(html代码),如何删除数组中未包含的其余选定数据。
$a = 0;
foreach (array_combine($eQues, $eQuesID) as $eQuest => $eQuestID){
    if ($a < $tempCount){ // Update Question
        $sql="UPDATE log_question SET ques_item='$eQuest' WHERE ques_id='$eQuestID'";
        $test=mysqli_query($con, $sql);
        //Check whether the query was successful or not
        if(!$test) {
            echo("Error description: " . mysqli_error($con));
            exit();
        }
    } else { //Insert New Question
        $newsql="INSERT INTO log_question VALUES('', '$eID', '$eQuest')";
        $newtest=mysqli_query($con, $newsql);
        //Check whether the query was successful or not
        if(!$newtest){
            echo("Error description: " . mysqli_error($con));
            exit();
        }
    } $a++;
}