mysql_connect('localhost','root','password');
mysql_select_db('database_name');
$query=mysql_query("select count(*) total from table where field='111'");
$array=mysql_fetch_array($query);
if($array['total']>0)
{
mysql_query('delete from table where field=111');
}
else
{
echo '没有';
}根据自己的东西更改上面的内容
http://www.php.net/manual/en/refs.database.php先看看这个,希望你能自己解决
简略表示一下: $result=$db—>query(SELECT code ,COUNT(*) AS flg FROM A WHERE code=$code);
$r= array();
if($result->flg == 0) {r['flg'] = "没有";}
else{ r['flg'] ="有";
$db—>query(DELETE * FROM A WHERE code = $code );} $this->dispaly();