I am working on a large website with over 1 mil products that are separated into manufacturers, however some of the categories (or manufacturers) have 30 k products. The customer requested that I split these into 1,000 per category. I am working from a batch of excels that I imported into my home server and this is what I have for now, I am adding an incremented number as a sub category. its obviously not working since im here. Thanks in advance for your help.
[php]
function distinct_manus() {
global $c;
$q = " SELECT DISTINCT Manufacturer as Manufacturer ";
$q .= " FROM products ";
$r = mysql_query($q, $c);
confirm_query($r);
return $r;
}
function distinct_manu_prods($Manufacturer) {
global $c;
$q = " SELECT * ";
$q .= " FROM products “;
$q .= " WHERE Manufacturer =’$Manufacturer’”;
$r = mysql_query($q, $c);
confirm_query($r);
return $r;
}
$num_passes=0;
$distinct_manus = distinct_manus();
while ($distinct_manu = mysql_fetch_array($distinct_manus)){
$Manufacturer = $distinct_manu[Manufacturer];
$products = distinct_manu_prods($Manufacturer);
$num_products = mysql_num_rows($products);
if (mysql_num_rows($products) > 1000) {
while ($product = mysql_fetch_array($products)){
$run = $product[Category]."||1";
$q = “UPDATE products SET Category = {$run}”;
if (mysql_query($q,$c)){echo “Edit Successful.”;
} else {echo "Error message = ".mysql_error();}
}
}
}
[/php]