Ver Mensaje Individual
  #3 (permalink)  
Antiguo 12/06/2007, 16:49
Avatar de sidney rees
sidney rees
 
Fecha de Ingreso: julio-2006
Ubicación: Argentina
Mensajes: 334
Antigüedad: 17 años, 10 meses
Puntos: 16
Re: PHP-MySQL-XML : Carga de datos muy lenta

Upsss... este el PHP que genera el XML, está un poco caotico porque lo estuve modificando y luego me decidí por hacer directamente los archivos XML.

Gracias por tu ayuda Falhor!

Cita:
<?php
include('config.php');

$categoria = utf8_decode($_POST["categoria"]);
$tipo = utf8_decode($_POST["tipo"]);
$cat = utf8_decode($_POST["cat"]);

if ($tipo=="Categoria" && $categoria=="Categorías"){$name = 1;}
else if ($tipo=="Categoria"){$name = 2;}
else if ($tipo=="Sub" && $categoria=="Todas"){$name = 3;}
else if ($tipo=="Sub") {$name = 4;}
else if ($tipo=="Busqueda"){$name = 6;};

switch ($name) {
case 1:
$productos=mysql_query("SELECT id, nombre, descripcion, precio, imagen, categoria, marca, highlight1, highlight2 FROM productos");
break;
case 2:
$productos=mysql_query("SELECT id, nombre, descripcion, precio, imagen, categoria, marca, highlight1, highlight2 FROM productos WHERE categoria = '$categoria'");
break;
case 3:
$productos=mysql_query("SELECT id, nombre, descripcion, precio, imagen, categoria, marca, highlight1, highlight2 FROM productos WHERE categoria = '$cat'");
break;
case 4:
$productos=mysql_query("SELECT id, nombre, descripcion, precio, imagen, categoria, marca, highlight1, highlight2 FROM productos WHERE categoria = '$cat' AND highlight1 = '$categoria'");
break;
case 5:
$productos=mysql_query("SELECT id, nombre, descripcion, precio, imagen, categoria, marca, highlight1, highlight2 FROM productos WHERE nombre LIKE '$categoria' OR categoria LIKE '$categoria' OR highlight1 LIKE '$categoria' OR highlight2 LIKE '$categoria' OR marca LIKE '$categoria'");
break;
}

$Return="<?xml version=\"1.0\" encoding=\"utf-8\"?><!DOCTYPE catalog []><catalog>";

while ($field = mysql_fetch_object($productos))
{
$Return.="<product ";
$Return.="productId=\"".$field->id."\">";
$Return.="<name>".$field->nombre."</name>";
$Return.="<description>".$field->descripcion."</description>";
$Return.="<price>".$field->precio."</price>";
$Return.="<image>".$field->imagen."</image>";
$Return.="<series>".$field->categoria."</series>";
$Return.="<highlight1>".$field->highlight1."</highlight1>";
$Return.="<highlight2>".$field->highlight2."</highlight2>";
$Return.="<marca>".$field->marca."</marca>";
$Return.="</product>";
}

$Return.="</catalog>";

mysql_free_result($productos);
print $Return;
?>
__________________
¿Tienes problemas para terminar tu proyecto? Nosotros te ayudamos, visitanos en Sidneyrees.com