欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

PHP查詢并刪除數(shù)據(jù)庫多列重復數(shù)據(jù)的方法(利用數(shù)組函數(shù)實現(xiàn))

 更新時間:2016年02月23日 09:36:17   作者:xxzqyall  
這篇文章主要介紹了PHP查詢并刪除數(shù)據(jù)庫多列重復數(shù)據(jù)的方法,利用數(shù)組函數(shù)實現(xiàn)該功能,涉及PHP數(shù)據(jù)庫操作的相關技巧,需要的朋友可以參考下

本文實例講述了PHP查詢并刪除數(shù)據(jù)庫多列重復數(shù)據(jù)的方法。分享給大家供大家參考,具體如下:

<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
    die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db("test_db", $con);
if (!$db_selected)
{
    die ("Can/'t use test_db : " . mysql_error());
}
$sql = "SELECT * FROM friend";
$result=mysql_query($sql,$con);
while($myrow=mysql_fetch_row($result))
{
    $arr_data[$myrow[0]]=$myrow[1]."-".$myrow[2];
}
$arr_unique=array_unique($arr_data);
$arr_rep=array_diff_assoc($arr_data,$arr_unique);
//顯示前后量
echo count($arr_data)."-".count($arr_unique);
foreach($arr_rep as $key=>$value){
  $sql_del = "DELETE FROM friend WHERE id = '{$key}' ";
  $result=mysql_query($sql_del,$con);
}
// 一些代碼
mysql_close($con);
?>

更多關于PHP相關內容感興趣的讀者可查看本站專題:《php面向對象程序設計入門教程》、《php字符串(string)用法總結》、《php+mysql數(shù)據(jù)庫操作入門教程》及《php常見數(shù)據(jù)庫操作技巧匯總

希望本文所述對大家PHP程序設計有所幫助。

相關文章

最新評論