Hello,
I have a query that is suppose to pull each category key from the database. However it pulls duplicates.
Say my categories and their keys are:
Electronics -> 12
Industrial -> 13
Medical -> 14
Electronics -> 15
The query will pull the category keys and display them as this: 12,13,14,12
Here is my code:
for($db=1;$db<=$counter;$db++) {
//print $mainC[$db];
mysql_query("INSERT INTO maincat (pageKey, catTitle) VALUES ('$pageKey','$mainC[$db]')");
$catQuery = "SELECT DISTINCT catKey FROM maincat WHERE pageKey='$pageKey' AND catTitle='$mainC[$db]'";
$query = mysql_query($catQuery);
$row = mysql_fetch_array($query);
$catKey = $row['catKey'];
print $catKey;
}
$mainC[$db] represents the category title. I.E. Electronics.
If anyone can help I would appreciate it. Thanks.