Re: [Damon] Listing duplicate records
Hi Damon,
Thanks for answering. Basically, I was trying to search a mySQL database to find the number of instances of a record based on the [unique] information contained in one of the fields. Example: Finding how many times a user's phone number occurs when the record is accessed. All I really needed was the count.
[tongue] (My) Solution:
<?php
$phon_num = '123-456-7890'; // can also be a variable brought over from another file via 'include' for multiple look-ups
$con = mysql_connect("localhost","database","table");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("database", $con);
$query = "SELECT count(phone_number) FROM table WHERE phone_number='$phon_num'";
$pnums= mysql_result (mysql_query ($query), 0);
// $pnums = the number of times the phone number occurs
echo 'The phone number '.$phon_num. ' occurs '.$pnums. 'times';
?>
Again, thanks for answering! [;)]
Eric