📄 class_add.php
字号:
<?php
require_once("../admin/admin.php");
require_once('../config/conn.php');
if($_REQUEST['Submit'])
{
$sort=$_POST['sort'];
$class1=trim($_POST['class1']);
}
switch($_REQUEST['abc'])
{
case 1 :
$result=mysql_query("insert into fenlei(fname,sort) values('$class1','$sort')");
header("location:../manage/main.php");
exit;
break;
case 2 :
$result=mysql_query("select * from fenlei where id=".$_GET['noid']);
$row=mysql_fetch_assoc($result);
$name=$row['fname'];
$noid=$row['id'];
mysql_free_result($result);
unset($row);
break;
case 3 :
$result=mysql_query("update fenlei set fname='$class1' where id=".$_POST['noid']);
header("location:../manage/main.php");
exit;
break;
case 4 :
$noid=$_GET['noid'];
$path=$_SERVER['DOCUMENT_ROOT'];
$pathfile=$path."/newpic/";
$query2="select * from fenlei where id in ($noid)";
$result2=mysql_query($query2);
while($row2=mysql_fetch_assoc($result2))
{
$fid=$row2['id'];
$query="select id,images,imagecon from datas where class in ($fid)";
$result=mysql_query($query);
while($row=mysql_fetch_assoc($result))
{
$file=$pathfile.$row['images'];
if(file_exists($file)) unlink($file);
$file1=$row['imagecon'];
if($file1<>'无')
{
$file_str=strstr($file1,',');
if($file_str)
{
$file_na=explode(',',$file1);
foreach($file_na as $str1)
{
if(file_exists($pathfile.$str1)) unlink($pathfile.$str1);
}
}
else
{
if(file_exists($pathfile.$file1)) unlink($pathfile.$file1);
}
}
$sql="delete from pinglen where nid=".$row['id'];
$result1=mysql_query($sql);
}
mysql_free_result($result);
unset($query);
}
$sql="delete from datas where class in (".$noid.")";
$result1=mysql_query($sql);
$sql="delete from fenlei where id in(".$noid.")";
$result=mysql_query($sql);
header("location:../manage/main.php");
exit;
break;
}
$result=mysql_query("select * from fenlei where sort=0");
while($row=mysql_fetch_assoc($result))
{
$result1=mysql_query("select * from fenlei where sort=".$row['id']);
if(mysql_num_rows($result1)<>0)
{
while($row1=mysql_fetch_assoc($result1)) $str1.='<li>'.$row1['fname'].'</li>';
$str1="<ul>".$str1."</ul>";
mysql_free_result($result1);
unset($row1);
}
$str.='<ul><li>'.$row['fname'].$str1.'</li></ul>';
unset($str1);
$selet.='<option value="'.$row['id'].'">'.$row['fname'].'</option>';
}
mysql_free_result($result);
unset($row);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<link href="../config/css.css" rel="stylesheet" type="text/css">
<script src="../config/common.js" language="JavaScript" type="text/JavaScript"></script>
<script language="JavaScript" type="text/JavaScript">
function check()
{
if(IsEmpty(form1.class1,"分类名称不能为空,请填写。")) return false;
}
</script>
</head>
<body>
<br>
<table width="600" height="600" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="top"> <form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>" onSubmit="return check();">
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
<caption class="title">
新闻分类的增加
</caption>
<tr class="zhenwei">
<td width="100" height="40" align="right" valign="top"> 已经有分类:</td>
<td width="400" height="40" align="left" valign="middle"><?php echo $str; ?></td>
</tr>
<tr class="zhenwei">
<td height="40" align="right" valign="middle">隶属分类:</td>
<td height="40"><select name="sort" id="sort">
<option value="0" selected>顶级分类</option>
<?php echo $selet;?>
</select></td>
</tr>
<tr class="zhenwei">
<td width="100" height="40" align="right" valign="middle">分类名称:</td>
<td width="400" height="40"> <input name="class1" type="text" id="class" size="20" maxlength="4" value="<?php echo $name; ?>">
<font color="#FF0000">*请写四个字的分类名称。</font></td>
</tr>
<tr align="center" class="zhenwei">
<td height="40" colspan="2" valign="middle">
<?php
if($name)
{
?>
<input name="noid" type="hidden" id="noid" value="<?php echo $noid;?>">
<input name="abc" type="hidden" id="abc" value="3"> <input type="submit" name="Submit" value=" 修改分类 ">
<?php
}
else
{
?>
<input name="abc" type="hidden" id="abc" value="1"> <input type="submit" name="Submit" value=" 保存分类 ">
<?php }?>
</td>
</tr>
</table>
</form></td>
</tr>
</table>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -