任何人都可以教我如何连续获取数据的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>
";
}
答案 0 :(得分: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
答案 1 :(得分:0)
while($row = mysqli_fetch_assoc($result))
{
echo $row['id'];
echo " ";
echo $row['name'];
echo " ";
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]
获取要删除的行ID的值。