-1
請看看下面的循環:刪除行從數據庫中使用PHP /庫MySQLi
$category = $mysqli->query('SELECT * FROM category');
$divcounter = 0;
while($row = $category->fetch_assoc()) {
print '<div class="item col-xs-12 col-sm-6 col-md-3 col-lg-2">';
print '<h4><a href="#tvb'.$row["id"].'" data-toggle="collapse" aria-expanded="false" aria-controls="tvb'.$row["id"].'" class="label label-success full-width"><span class="glyphicon glyphicon-triangle-right" aria-hidden="true"></span> '.$row["catname"].'</a></h4>';
print '<div id="tvb'.$row["id"].'">';
$link = $mysqli->query("SELECT * FROM links WHERE category='{$row["id"]}'");
while($row = $link->fetch_assoc()) {
print '<li><a href="'.$row["url"].'">'.$row["name"].'</a> <span class="glyphicon glyphicon-remove text-danger" aria-hidden="true"></span></li>';
}
$link->free();
print '</div>';
print '</div>';
$divcounter++;
!($divcounter % 2) ? print '<div class="clearfix visible-sm-block"></div>' : '';
!($divcounter % 4) ? print '<div class="clearfix visible-md-block"></div>' : '';
!($divcounter % 6) ? print '<div class="clearfix visible-lg-block"></div>' : '';
}
請告訴我如何創建一個按鈕,坐在旁邊的李從資料庫中刪除,目前上市行?由於
<span class="glyphicon glyphicon-remove text-danger" aria-hidden="true"></span>
這是delete.php的內容:
if(isset($_POST['catid']) and is_numeric($_POST['catid']))
$id=$_POST['catid'];
$query = "DELETE FROM category WHERE id=(?)";
$statement = $mysqli->prepare($query);
$statement->bind_param('i', $id);
$statement->execute();
$statement->close();