note 27338 added to function.mysql-query
| From: | sunist at uo-casino dot com | Date: | Mon, 02 Dec 2002 18:02:27 +0000 |
| Subject: | note 27338 added to function.mysql-query | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-40256@lists.php.net to get a copy of this message | ||
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);}
--
http://www.php.net/manual/en/function.mysql-query.php
http://master.php.net/manage/user-notes.php?action=edit+27338
http://master.php.net/manage/user-notes.php?action=delete+27338
http://master.php.net/manage/user-notes.php?action=reject+27338