نوشته شده توسط
thacker
لطفا کد مربوط به صفحتون رو اینجا بگذارید تا بر اساس اون راهنماییتون کنیم
<script>
function checkall(value)
{
if($("#check").is(":checked"))
{
$(".check").attr("checked","checked");
}
else
{
$(".check").removeAttr("checked");
}
}
</script>
<style>
table
{
min-width: 100px;
}
table tr
{
min-height: 50px;
border: 1px solid red;
}
table tr th
{
padding: 10px;
text-align: center;
padding-bottom: 10px;
color: red;
}
table tr td
{
padding: 10px;
text-align: center;
padding-top: 5px;
}
</style>
</head>
<body>
<form action="deleteall.php " method="post">
<table>
<tr>
<th>
شماره
</th>
<th>
عنوان
</th>
<th>
متن
</th>
<th>
تاریخ ایجاد
</th>
<th>
تاریخ نمایش
</th>
<th>
تاریخ پایان نمایش
</th>
<th>
حالت
</th>
<th>
ایجاد کنننده
</th>
<th>
ویرایش
</th>
<th>
حذف
</th>
<th> <span class=' glyphicon glyphicon-ok'></span><input type="checkbox" id="check" onChange="checkall(this.value)">
</th>
</tr>
<?php
include"config.php";
$q=mysqli_query($link,"SELECT * FROM content")OR DIE(mysqli_error($link));
$row=mysqli_num_rows($q);
if($row=='0')
{
echo"داده ای موجود نمی باشد";
}
else
{
while($r=mysqli_fetch_assoc($q)){
echo"<tr>";
foreach($r as $val)
echo"<td>" .$val."</td>";
echo"<td><a href='index.php?page=content&editid=$r[id]'><span class='glyphicon glyphicon-edit'></span></a></td><td><a href='delete.php?deleteid=$r[id]'><span class='glyphicon glyphicon-remove'></span></a></td><td><input type='checkbox' class='check' value='$r[id]' name='ckeckid[]'/></td></tr>";
}
}
?>
</table>
<div>
<input type="submit" value="deleteall">
</div>
</form>
</body>
تا اینجا چک باکس ها تو چدول تیک میخوره وبرای هر چک باکس مقدار value رو Id قرار دادم حالا میخوام تو صفحه ی جدا که بتونم چند تا رو با هم حذف کنم تو اون صفحه نمیدونم چه جوری بنویسم
تو صفحه ی مربوط به deletallهم اینارو نوشتم
<?php
include("config.php");
$delid=$_POST['ckeckid[]'];
foreach($delid as $val)
mysqli_query($link,"DELETE FROM content WHERW id=".$val)
?>