note 27338 deleted from function.mysql-query by philip

From: Date: Wed, 06 Apr 2005 18:10:06 +0000
Subject: note 27338 deleted from function.mysql-query by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-87608@lists.php.net to get a copy of this message
Note Submitter: sunist at uo-casino dot com ---- Here is a quick code i've made to cleanup any duplicate entry from a mysql table. Hope it'll help :) Sunist. $table = "yourtablename"; $recup_champs = mysql_query("select * from $table"); $recup_all = "select * from $table "; while ($i < mysql_num_fields($recup_champs)) { $array_table[] = mysql_field_name($recup_champs, $i);$i++;} $bla = mysql_query($recup_all); while ($row = mysql_fetch_array($bla)) {$this_query = "delete from $table where ".$array_table[0]."<>".$row[0]; for ($a=1;$a<count($array_table);$a++) {$this_query .= " AND ".$array_table[$a]."='".$row[$a]."'"; } $this_query .=";"; mysql_query($this_query);}

« previous php.notes (#87608) next »