-1

任何人都可以教我如何连续获取数据的ID,然后传递到delete.php。我不知道该怎么做。我对此很陌生.. tnx 很多。

 while($row = mysqli_fetch_assoc($result))
 {

    echo $row['id'];
    echo "   ";
    echo $row['name'];
    echo "   ";
    echo "<form id='form' action='delete.php'>";
    echo "<input type='button' value='submit' id='btn".$row['id']."' name='but'>";
    echo "<br>";

    echo "
    <script>
    $('#btn".$row['id']."').click(function() {
    alertify.confirm('Delete the selected entry?',function(e){
        if(e) {
            $('#form').submit();
            return true;
        } else {
            return false;
        }

    });
     });
     </script>
     ";
 }
4

2 回答 2

1
echo "<form id='form'  action='delete.php'>";
echo "<input type='hidden' name='delete' value='' $row['id']."' >"; 
echo "<input type='button'  class='btn_del' >";
echo "<br>";
now in js

<script>
$('.btn").click(function() {
alertify.confirm('Delete the selected entry?',function(e){
if(e) {
$('#form').submit();
return true;
} else {
 return false;
}

});
});
</script>
then get value in delete.php by
$is=$_REQUEST['delete'];
// your query here
于 2016-10-27T23:25:56.667 回答
0
while($row = mysqli_fetch_assoc($result))
 {

    echo $row['id'];
    echo "&nbsp;&nbsp;&nbsp;";
    echo $row['name'];
    echo "&nbsp;&nbsp;&nbsp;";
    echo "<form id='form' action='delete.php'>";
echo "<input type='hidden' name='rowid' value='".$row['id']."' >"; 
    echo "<input type='button' value='submit' id='btn".$row['id']."'>";
    echo "</form><br>";

    echo "
    <script>
    $('#btn".$row['id']."').click(function() {
    alertify.confirm('Delete the selected entry?',function(e){
        if(e) {
            $('#form').submit();
            return true;
        } else {
            return false;
        }

    });
     });
     </script>
     ";
     }

在 delete.php 中使用$_POST[rowid]来获取要删除的row id的值。

于 2016-10-28T01:33:50.063 回答