Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/382.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在alertify确认删除中获取id_Javascript_Php_Html_Mysql_Alertify - Fatal编程技术网

Javascript 如何在alertify确认删除中获取id

Javascript 如何在alertify确认删除中获取id,javascript,php,html,mysql,alertify,Javascript,Php,Html,Mysql,Alertify,有人能教我如何获取一行数据的id,然后将其传递到delete.php中吗。我不知道怎么做,我对这个很陌生。。tnx很多 while($row = mysqli_fetch_assoc($result)) { echo $row['id']; echo "&nbsp;&nbsp;&nbsp;"; echo $row['name']; echo "&nbsp;&nbsp;&nbsp;"; echo "<

有人能教我如何获取一行数据的id,然后将其传递到delete.php中吗。我不知道怎么做,我对这个很陌生。。tnx很多

 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='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>
     ";
 }
while($row=mysqli\u fetch\u assoc($result))
{
echo$row['id'];
回声“;
echo$row['name'];
回声“;
回声“;
回声“;
回声“
”; 回声“ $('#btn.“$行['id'..”)。单击(函数(){ alertify.confirm('Delete the selected entry?'),函数(e){ 如果(e){ $('表格').submit(); 返回true; }否则{ 返回false; } }); }); "; }
echo”“;
echo“
while($row=mysqli\u fetch\u assoc($result))
{
echo$row['id'];
回声“;
echo$row['name'];
回声“;
回声“;
回声“;
回声“;
回声“
”; 回声“ $('#btn.“$行['id'..”)。单击(函数(){ alertify.confirm('Delete the selected entry?'),函数(e){ 如果(e){ $('表格').submit(); 返回true; }否则{ 返回false; } }); }); "; }
在delete.php中
使用
$\u POST[rowid]
获取要删除的行id的值。

首先传播您的逻辑和html。我应该将其放在delete.php文件中吗?->$id=$POST['delete'];其中u wana获取id并使用IDI进行一些操作,而不仅仅是删除第一行,当我删除第二行、第三行或第四行时,它总是删除第一行
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
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>
     ";
     }