Author Topic: Match two entires from a query result  (Read 421 times)

0 Members and 1 Guest are viewing this topic.

Offline brobTopic starter

  • Irregular
  • Posts: 37
    • View Profile
Match two entires from a query result
« on: February 05, 2007, 08:36:32 AM »
I'm pulling a query from a database and want to check to see if there are any duplicates.

I don't want to remove the duplicates but display the id of them.

Does anyone know how to do this?

Thanks

Offline Balmung-San

  • Enthusiast
  • Posts: 353
  • Gender: Male
  • L knew it was coming.
    • View Profile
    • Knights of Heaven
Re: Match two entires from a query result
« Reply #1 on: February 05, 2007, 08:42:00 AM »
Well, to check for duplicates I'd use mysql_num_rows. As for displaying the id, a loop through them is the only method I know about.

Code: [Select]
<?php
//connect...
//query
if(mysql_num_rows($result) > 1)
{
//display ids
while($data mysql_fetch_array($result))
{
echo 
$data['id'];
}
}
else
{
}
?>
"Paranoia is very useful in this work. ...If your cryptographic system can survive the paranoia model, it has at least a fighting chance of surviving in the real world." - Niels Ferguson & Bruce Schneier

They say there's more then one way to skin a cat.
In programming, there's no wrong way to skin a cat, just more efficent ways of doing so.

Offline phat_hip_prog

  • Enthusiast
  • Posts: 145
  • Gender: Male
    • View Profile
    • www.rawstar7.co.uk
Re: Match two entires from a query result
« Reply #2 on: February 05, 2007, 08:46:33 AM »
Here's a little ref, look at the replies:
http://uk2.php.net/manual/en/function.array-unique.php