Total members 11894 |It is currently Sun Nov 24, 2024 12:57 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Code:
<?php

/* Removes duplicate records in a table

Code by:
Bardhyl Fejzullahi
[email protected]
17.09.2008
Pristina, Kosovo

EX.
|id|name|
==========
|1|test|
----------
|2|php|
----------
|3|test|
----------
Result
|id|name|
==========
|1|test|
----------
|2|php|
----------
*/


$cnmysql_connect("localhost""root""") or die('Could not connect');
$dbmysql_select_db(test$cn) or die('Could not select database');


    
$query="SELECT * FROM name"
       
    
$result=mysql_query($query);
    echo 
mysql_error();


        while(
$row mysql_fetch_array($resultMYSQL_BOTH))
       
        {
                
$query1="SELECT * FROM tablename WHERE name = '".$row[1]."'"
       
                
$result1=mysql_query($query1);
                
$count mysql_num_rows($result1) - 1;
               
                
mysql_query("DELETE FROM tablename WHERE name='".$row[1]."' LIMIT $count");
                echo 
"deleted $row[1] <br>";
           
}
        echo 
mysql_error();
    
?>
       

-- 
Bardhi




_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time

hi plz define $link variable.


Author:

it is a bug , i deleted it.

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 3 posts ] 

  Related Posts  to : delete duplicate rows in mysql using php
 three rows frameset .     -  
 Select odd rows from table     -  
 Get affected rows for an update in php     -  
 Listing All Rows and Fields in a Table     -  
 different colors for table Even- Odd rows and Cells     -  
 Number of Rows Returned by query in php     -  
 Multi colored table rows     -  
 Randomly generated rows and columns in Array     -  
 Uneven rows-2-dimenstionals-triangle look like 2D array     -  
 Delete file     -  



Topic Tags

PHP Database
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com