if ($action=="subir") {
copy($File, DIR_FS_CATALOG_IMAGES . $File2);
$cate_file=fopen(DIR_FS_CATALOG_IMAGES . "catart.txt","r");
while (!feof($cate_file)){
$trozos=array();
$linea=fgets($cate_file);
echo $linea . '<br>';
$trozos=explode(';',$linea);
if(strval($trozos[11])==0) {
$trozos[11]=NULL;
}
if($trozos[12]=='0') $trozos[12]='';
if($trozos[2]=='0') $trozos[2]='';
if (strlen($trozos[0]>0)) {
$consulta=tep_db_query('select * from products,categories where categories.categories_code="' . $trozos[1] . '" and products.products_code="' . $trozos[0] . '"');
if (($consulta1 = tep_db_fetch_array($consulta))){
//tep_db_query('update products_to_categories set categories_code="' . $trozos[1] . '" , products_code="' . $trozos[0] . '" where categories_id=' . $consulta1['categories_id'] and 'products_id=' . $consulta3['products_id']);
echo 'Actualizado ...';
$products_id = $consulta1['products_id'];
$categories_id = $consulta1['categories_id'];
$products_code = $consulta1['products_code'];
$categories_code = $consulta1['categories_code'];
echo 'productos id';
echo $products_id;
echo 'productos codigo';
echo $products_code;
echo 'Categorias id';
echo $categories_id;
echo 'Categorias codigo';
echo $categories_code;
}
else {
$consulta=tep_db_query('select * from products,categories where categories.categories_code="' . $trozos[1] . '" and products.products_code="' . $trozos[0] . '"');
$consulta1 = tep_db_fetch_array($consulta);
echo var_dump($consulta1);
$products_id = $consulta1['products_id'];
$categories_id = $consulta1['categories_id'];
//tep_db_query("INSERT INTO products_to_categories (categories_id,products_id,products_code,categories_code) VALUES (" . $categories_id . "," . $products_id . ",'" . $trozos[0] . "','" . $trozos[1] . "')");
$categories_id = tep_db_insert_id();
//tep_db_query("insert into categories_description (categories_id,categories_name) values (" . $categories_id . ", '" . $trozos[2] . "')");
echo 'Agregado...';
//echo var_dump($consulta1);
echo $products_id;
echo $categories_id;
}
echo $trozos[2] . '<br>';
}
}
fclose($cate_file);
//echo tep_redirect('categories.php');
}