I am importing data from a file. One of the fields contains category data for my shopping cart.
The data is in the form of this
level1|level2|level3|level4
I am using the following code to split up the data into an array
while($data = mysql_fetch_array($categories_results, MYSQL_ASSOC)){
$product_id = $data['PRODUCT_ID'];
$categories = $data['CATEGORIES'];
$category_array = explode("|", $categories);
//echo ($category_array."<br />");
//print_r($category_array);
@$Level2 = $category_array[1];
@$Level3 = $category_array[2];
@$level4 = $category_array[3];
$num = $cnt++;
$category_id = $num;
$insert_sql = "INSERT IGNORE INTO va_categories (`category_id`,`category_name`) VALUES ('$category_id','$Level2')";
$insert_results = mysql_query($insert_sql,$dbConn);
$update_sql = "UPDATE va_categories SET is_showing = '1'";
$update_results = mysql_query($update_sql,$dbConn);
What this is doing is basically pulling the informtion in the second level of the category array and giving it an id number for the site.
The problem I have is that there are more then one item with the same name. Since I dont want duplicate categories to show on the site...
I need to only take one instance of each category and ignore the rest...
can someone tell me how I can do this?
Thanks