<?php
require('includes/application_top.php');
$selectsql = "select categories_id from categories_description where language_id = 1";
$select_count_products_off = "select count(*) from products where products_status = 0";
$count_products_off = $db->Execute($select_count_products_off);
$cateid = $db->Execute($selectsql);
$i = 0;
while(!$cateid->EOF)
{
$cateidone = $cateid->fields[categories_id];
$updatesql = "update products set products_status = 1 where products_status = 0 and master_categories_id = ".$cateidone." limit 1";
$db->Execute($updatesql);
$select_categories_name = "select categories_name from categories_description where categories_id = " .$cateidone." and language_id = 1";
$select_products_count_off = "select count(*) as cd from products where products_status = 0 and master_categories_id = ".$cateidone;
$caterst = $db->Execute($select_categories_name);
$prorst = $db->Execute($select_products_count_off);
if($prorst) continue;
$categrid[$i]['name'] = $caterst->fields[categories_name];
$categrid[$i]['count'] = $prorst->fields[cd];
$i = $i+1;
$cateid->MoveNext();
}
echo 'It is ok !!!<br />';
$select_products = "select count(*) as c from products where products_status = 0";
$res = $db->Execute($select_products);
echo 'left : '.$res->fields[c].'<br />';
foreach ($categrid as $value)
{
echo $value['name'] . " : [".$value['count'].']<br />';
}
?>