Copy CodeThe code is as follows:
$CN = mysql_connect (' 127.0.0.1 ', ' root ', ' root ') or Die (' Database connect fail ');
mysql_select_db (' Test ', $CN);
mysql_query ("Set names ' GBK '");
/*
Create a database tutorial
CREATE DATABASE ' test ';
Creating a data table Test1
CREATE TABLE ' test '. ' Test1 ' (
' ID ' INT (4) Not NULL auto_increment,
' title ' VARCHAR (+) NULL DEFAULT ' 0 ',
' Litpic ' VARCHAR (+) NULL DEFAULT ' 0 ',
PRIMARY KEY (' id ')
) ENGINE = MYISAM
*/
$sql = "SELECT * from Test1";
$query = mysql_query ($sql) or Die ($sql);
if (mysql_num_rows ($query))
{
while ($rs = Mysql_fetch_array ($query))
{
$sql = "Delete from test1 where id=". $rs [' id '];
if (mysql_query ($sql))
{
if (Defile ($rs [' litpic ']))
{
echo ' Delete picture file failed ';
}
Else
{
Echo ' record deleted successfully, and deleted the picture or file corresponding to the record ';
}
}
Else
{
Echo ' record does not save deleted data and image failed ';
}
}
}
Else
{
Echo ' no record ';
}
/*
@pare return
# $url String
deleting files
*/
function Delfile ($url)
{
if (file_exists ($url) && is_file ($url))
{
if (unlink ($url))
{
return true;
}
Else
{
return false;
}
}
Else
{
return false;
}
}
http://www.bkjia.com/PHPjc/321780.html www.bkjia.com true http://www.bkjia.com/PHPjc/321780.html techarticle Copy the code as follows: $CN = mysql_connect (' 127.0.0.1 ', ' root ', ' root ') or Die (' Database connect fail '); mysql_select_db (' Test ', $ CN); mysql_query ("Set names ' GBK '"); /* Create Data ...