i need to return a list from a database and check whether or not an element in that list occurs more than once.
if it occurs more than once, id like to add that element to an array.
what would be the best way to do this?
so far i have this:
$query = "SELECT DISTINCT bid FROM videomail_broadcast_flv WHERE id = '$id'";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
for ($i=0; $i<$num_results; $i++) {
$row = mysql_fetch_array($result);
$bid = $row['bid'];
$bidArray[count($bidArray)] = $bid;
}
for ($j=0; $j<count($bidArray); $j++) {
$query = "SELECT * FROM videomail_broadcast_flv WHERE bid = '$bidArray[$j]' AND id = '$id'";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
echo "j = $j - ";
if ($num_results > 1) {
$duplicateArray[$j] = $bidArray[$j];
}
echo "$duplicateArray[$j]<br />";
}
the only problem with this is that it will skip over spots in the array creating blank spaces in the array.
any help is much appreciated!
thanks guys 😃