<?php
/**
*图片管理
* 2011/8/20
* kcj
* */
include "isLogin.php";
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>后台管理</title>
<meta name="Author" content="kcj" />
<meta name="Keywords" content="php,lampbrother" />
<link rel="stylesheet" type="text/css" href="style/lampcms.css">
<script src="javascript/common.js"></script>
</head>
<body>
<div id="main">
后台管理->文章管理
<form method="post" action="" >
<div class="msg-box">
<ul class="viewmess">
<li class="dark-row">
<span class="list_width width_font">图片名称</span>
<span class="list_width width_font">图片路径</span>
<span class="list_width width_font">添加时间</span>
<span class="list_width width_font">操作</span>
</li>
<?php
/**
* 图片管理
* 2011/8/20
* kcjs
**/
require "../conn/conn.php";
if($_GET["del"]){ //删除图片信息及文件夹下的图片(注意不要犯逻辑性的错误,当然可以分开写这两个的删除)
$id=$_GET["del"];
$sql2="select*from pic where id=".$id;
$rst2=mysql_query($sql2);
$row=mysql_fetch_array($rst2);
$sql="delete from pic where id=".$id;
mysql_query($sql);
$filename=$row['picpath'];
if(file_exists($filename)){
unlink($filename);
}else {
echo "图片路径不正确";
}
}
$sql="select*from pic";
$rst=mysql_query($sql);
$totalnum=mysql_num_rows($rst); //print_r($totalnum);exit;
$pagenum=5;
$page=$_GET["page"];
if($page==" "){
$page=1;
}
$begin=($page-1)*$pagenum;
$pagecount=ceil($totalnum/$pagenum);
$sql2="select * from pic order by id desc limit ".$begin.",".$pagenum." ";
$rst2=mysql_query($sql2);
while (@$row=mysql_fetch_array($rst2)){
?>
<li class="light-row" style="padding-top:2px; padding-bottom:2px">
<span class="list_width width_font"><a href="" target="_blank"><?php echo $row["picname"];?></a></span>
<span class="list_width width_font"><?php echo $row["picpath"];?></span>
<span class="list_width width_font"><?php echo $row["ctime"];?></span>
<span class="list_width width_font"><a href="editUpload.php?edit=<?php echo $row[id];?>">【修改】</a><a href="listUpload.php?del=<?php echo $row[id];?>">【删除】</a></span>
<?php
}
?>
<li class="dark-row">
<span class="right">
共<?php echo $totalnum;?>条 ;共<?php echo $pagecount;?>页;每页显示<?php echo $pagenum;?>条
<a href="<?php echo $_SERVER['PHP_SELF']?>?page=1">首页</a>
<a href="<?php echo $_SERVER['PHP_SELF']?>?page=<?php if($page>1) echo $page-1; else echo $page=1;?>">上一页</a>
<a href="<?php echo $_SERVER['PHP_SELF']?>?page=<?php if($page<$pagecount-1) echo $page+1; else echo $pagecount; ?>">下一页</a>
<a href="<?php echo $_SERVER['PHP_SELF']?>?page=<?php echo $pagecount;?>">尾页</a>
</span>
</li>
</ul>
</div>
</form>
</div>
</body>
</html>
php 数据库图片信息及文件夹下的图片删除
最新推荐文章于 2021-04-11 07:48:57 发布