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.
<?php
//connect...
//query
if(mysql_num_rows($result) > 1)
{
//display ids
while($data = mysql_fetch_array($result))
{
echo $data['id'];
}
}
else
{
}
?>