<span class="code"><?php <br/> mysql_connect('localhost','',''); //添加相应的mysql主机名,用户名,密码<br> mysql_select_db(''); //添加相应的mysql的数据库名<br> $sql = "SELECT * FROM ''"; //添加相应的数据表的名字<br> $query = mysql_query($sql);<br> $i = 0;<br> while($result = mysql_fetch_array($query))<br> {<br> <br> $sqlstr = "select * from smsorderinfo where ordermobile = '".$result['ordermobile']."' and itemkind = '".$result['itemkind']."'";<br> //echo "ordermobile = ".$result['ordermobile']." itemkind = ".$result['itemkind']."\n";<br> //echo "sqlstr = ".$sqlstr."\n";<br><br> if ($query1 = mysql_query($sqlstr))<br> {<br> //echo "成功\n";<br> while ($result1 = mysql_fetch_array($query1)) <br> {<br> if ($result['id'] != $result1['id']) <br> {<br> echo "发现重复: id1 = ".$result['id']." id2 = ".$result1['id']."\n";<br> //else echo "######################: id1 = ".$result['id']." id2 = ".$result1['id']."\n";<br> $sqlstr2 = "delete FROM `smsorderinfo` WHERE id = '".$result['id']."'";<br> //echo $sqlstr2;<br> if(mysql_query($sqlstr2))<br> {<br> echo "删除成功!\n";<br> }<br> else<br> echo "删除失败!";<br> }<br> }<br> }<br> //$arry[] = $result['ordermobile'].$result['itemkind'];<br> //echo $result['zuhe']."<br>";<br> $i++;<br> }<br> echo $i;<br>?></span> <p style="width:100%;text-align:center;margin:10px 0"> <br> <br> </p> <p style="width:100%;text-align:center;margin:10px 0"> </p> <p class="clear"></p>