xiaodao
11-26-2004, 11:03 AM
my thinking is use checkboxes, i click the checkboxes beside the news then click submit to delet those news checked
my script below, but did not work
<?
include 'config.php';
$sql=mysql_query("SELECT * FROM k_news ORDER BY newsid DESC");
echo "<form name='del' action='delnews.php' method=POST>";
echo "<table width=400 cellpadding=0 cellspacing=0>";
while($row=mysql_fetch_array($sql)) {
echo "<tr><Td>".$row['newstitle']."</td><td>".$row['date']."</td><td><input type='checkbox' name='delid[]' value=".$row['newsid']."</td></tr>";
}
echo "<tr><td colspan=3><input type=submit value=delet name=action></td></tr>";
echo "</table></form>";
if($action==delet) {
require_once 'config.php';
$newsid[]=$delid[];
for($n=0;$n<count($newsid),$n++)
{
$id=$newsid[$n];
$sql=mysql_query(DELET FROM k_news where newsid=$id) or die(mysql_error());
}
if (!$sql) {
echo"Cannot delet the news";
}
else
{ echo"News successfully deleted";
}
}
?>
error happens, says $newsid[]=$delid[]; is wrong, how to solve?
my script below, but did not work
<?
include 'config.php';
$sql=mysql_query("SELECT * FROM k_news ORDER BY newsid DESC");
echo "<form name='del' action='delnews.php' method=POST>";
echo "<table width=400 cellpadding=0 cellspacing=0>";
while($row=mysql_fetch_array($sql)) {
echo "<tr><Td>".$row['newstitle']."</td><td>".$row['date']."</td><td><input type='checkbox' name='delid[]' value=".$row['newsid']."</td></tr>";
}
echo "<tr><td colspan=3><input type=submit value=delet name=action></td></tr>";
echo "</table></form>";
if($action==delet) {
require_once 'config.php';
$newsid[]=$delid[];
for($n=0;$n<count($newsid),$n++)
{
$id=$newsid[$n];
$sql=mysql_query(DELET FROM k_news where newsid=$id) or die(mysql_error());
}
if (!$sql) {
echo"Cannot delet the news";
}
else
{ echo"News successfully deleted";
}
}
?>
error happens, says $newsid[]=$delid[]; is wrong, how to solve?