当我按下Delete按钮时,我想要删除在表格中选择的多行,我的代码是
的index.php
<?php
if(isset($_POST['Delete']))
{
for($i=0;$i<count($checkbox);$i++){
$ids= $checkbox[$i];
$query2="DELETE FROM products WHERE serialid='$ids'";
mysqli_query($conn,$query2);
}
}
$query2="SELECT * FROM products";
$allresult = mysqli_query($conn,$query2);
?>
<form method="POST" action="index.php">
<input type="button" class="btn btn-danger" name="Delete" value="Delete"/>
</form>
<table class="table table-striped table-hover table-responsive" id="inventoryTable">
<thead>
<tr>
<td>Serial ID</td>
<td>Name</td>
<td>Manufacturer</td>
<td>Keys</td>
<td>Description</td>
<td>Category</td>
<td>Block</td>
<td>Floor</td>
<td>Room</td>
</tr>
</thead>
<tbody>
<?php while($row = mysqli_fetch_array($allresult)) { ?>
<tr>
<td><input name="checkbox[]" type="checkbox" value="<?php echo $row['serialid']; ?>"></td>
<td><?php echo $row['serialid']?></td>
<td><?php echo $row['name'] ?></td>
<td><?php echo $row['manufacturer'] ?></td>
<td><?php echo $row['licensekeys'] ?></td>
<td><?php echo $row['description'] ?></td>
<td><?php echo $row['categoryname'] ?></td>
<td><?php echo $row['block'] ?></td>
<td><?php echo $row['floor'] ?></td>
<td><?php echo $row['room'] ?></td>
</tr>
<?php }?>
</tbody>
</table>
但每当我选择行并按下删除按钮时,没有任何反应。我有什么遗失的吗?
答案 0 :(得分:3)
在HTML页面上使用表单是完全错误的。表格应该如我所知。输入类型按钮错误,您必须更改提交..
TABLE_08292016
包装
<?php if(isset($_POST['Delete'])) { for($i=0;$i<count($_POST['checkbox']);$i++){ $ids= $_POST['checkbox'][$i]; $query2="DELETE FROM products WHERE serialid='".$ids."'"; mysqli_query($conn,$query2); } } $query2="SELECT * FROM products"; $allresult = mysqli_query($conn,$query2); ?> <form method="POST" action="index.php"> <input type="submit" class="btn btn-danger" name="Delete" value="Delete"/> <table class="table table-striped table-hover table-responsive" id="inventoryTable"> <thead> <tr> <td>Serial ID</td> <td>Name</td> <td>Manufacturer</td> <td>Keys</td> <td>Description</td> <td>Category</td> <td>Block</td> <td>Floor</td> <td>Room</td> </tr> </thead> <tbody> <?php while($row = mysqli_fetch_array($allresult)) { ?> <tr> <td><input name="checkbox[]" type="checkbox" value="<?php echo $row['serialid']; ?>"></td> <td><?php echo $row['serialid']?></td> <td><?php echo $row['name'] ?></td> <td><?php echo $row['manufacturer'] ?></td> <td><?php echo $row['licensekeys'] ?></td> <td><?php echo $row['description'] ?></td> <td><?php echo $row['categoryname'] ?></td> <td><?php echo $row['block'] ?></td> <td><?php echo $row['floor'] ?></td> <td><?php echo $row['room'] ?></td> </tr> <?php }?> </tbody> </table> </form>
元素中的所有详细信息。
答案 1 :(得分:1)
关闭表格的表格标签,然后只能获得帖子值。试试这样
var process = Process.Start(processPath);
process.WaitForInputIdle();
Console.WriteLine(process.MainWindowHandle)
while (process.MainWindowHandle == IntPtr.Zero)
{
Thread.Sleep(10);
}
//rest of the code
答案 2 :(得分:0)
<?php
if(isset($_POST['Delete']))
{
$delete = $_POST['checkbox'];
foreach ($delete as $ids) {
$query2="DELETE FROM products WHERE serialid = '".$ids."'";
mysqli_query($conn,$query2) or die("Invalid query");
}
}
$query2="SELECT * FROM products";
$allresult = mysqli_query($conn,$query2);
?>
<form method="POST" action="index.php">
<input type="submit" class="btn btn-danger" name="Delete" value="Delete"/>
<table class="table table-striped table-hover table-responsive" id="inventoryTable">
<thead>
<tr>
<td>Serial ID</td>
<td>Name</td>
<td>Manufacturer</td>
<td>Keys</td>
<td>Description</td>
<td>Category</td>
<td>Block</td>
<td>Floor</td>
<td>Room</td>
</tr>
</thead>
<tbody>
<?php while($row = mysqli_fetch_array($allresult)) { ?>
<tr>
<td><input name="checkbox[]" type="checkbox" value="<?php echo $row['serialid']; ?>"></td>
<td><?php echo $row['serialid']?></td>
<td><?php echo $row['name'] ?></td>
<td><?php echo $row['manufacturer'] ?></td>
<td><?php echo $row['licensekeys'] ?></td>
<td><?php echo $row['description'] ?></td>
<td><?php echo $row['categoryname'] ?></td>
<td><?php echo $row['block'] ?></td>
<td><?php echo $row['floor'] ?></td>
<td><?php echo $row['room'] ?></td>
</tr>
<?php }?>
</tbody>
</table>
</form>