当前位置:编程学习 > php >>

php 数据库图片信息及文件夹下的图片删除

<?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)

补充:Web开发 , php ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,