Jump to content

Checking for duplicate Rows


Demon_PHP

Recommended Posts

Hi,

 

First off i would like to let you know that am not talking about using submitting a form and then refreshing the page.

 

I am talking about a database that could have more than one of the same post.

 

I've been throwing some ideas around in my head. Below is my idea.

 

Foreach row as result

split each word into array from row['the_data_stuff'] into a variable lets say "words"

 

now foreach word as words

another query ... WHERE the_data_stuff like %word% and id is not row['id']

then cross check the words and give it add a point for every word matched an minus one for every word not matched.

 

Then if the score is high then a preset variable echo the two possible matches

 

I know thats a very bad way of doing it but before i go ahead and  make it.

 

Has anyone else got any ideas on how they would do it?

 

 

Link to comment
https://forums.phpfreaks.com/topic/192657-checking-for-duplicate-rows/
Share on other sites

To add on to my post this is what i made quickly but doesnt work.

 

$query="SELECT * FROM the_table WHERE viewable > 0 LIMIT 0,20";
$result=mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
$array=explode(" ", $row['the_joke']);	
$cid=$row['id'];
while($word =$array){
$query2="SELECT * FROM the_table WHERE viewable > 0 AND NOT id = '$cid' AND the_joke LIKE '%$word%' LIMIT 0,10";
$r=mysql_query($query2) or die(mysql_error());
while($crow = mysql_fetch_array($r)){
$crow_id=$crow['id'];
$the_results[$cid][$crow_id]++;
}


}
}

 

I used the LIMIT just to limit the loading time but it does work.

 

Any ideas?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.