Ver Mensaje Individual
  #5 (permalink)  
Antiguo 01/07/2011, 16:48
Avatar de dvbeaumont
dvbeaumont
 
Fecha de Ingreso: marzo-2011
Ubicación: Caracas
Mensajes: 145
Antigüedad: 14 años
Puntos: 1
Respuesta: Mostrar registros concatenados

santris

Si tenia un problema de diseño en base de datos. al final funcionó de la siguiente forma.
  • tipo
  • subtipo (pertenece al tipo)
  • marca (pertenece al subtipo)
  • modelo (pertenece al subtipo y la marca)

Pero ahora tengo un problema con la condición para evitar que si no hay modelos cargados en la marca no aparezcan.

Código PHP:
<?php 
  
include("admin/conexion2.php"); 
   
$linke=conectar2();
   
$result_a=mysql_query("select * from t_tipo ORDER BY id_tipo",$linke);
   while(
$row_a mysql_fetch_array($result_a)) { 
                      echo 
" <li><a href='#'>".$row_a["ti_name"]."</a>
                    <ul class='horizontal'>"
;
        
$tipo=$row_a["id_tipo"];            
   
$result_d=mysql_query("select * from t_subtipo WHERE id_tipo=".$tipo." ORDER BY id_tipo",$linke);
   while(
$row mysql_fetch_array($result_d)) { 
                      echo 
"
                        <li><a href='#'>"
.$row["su_name"]."</a>";
                        echo
"<div class='extended'>";
                        echo
"<ul class='smallNav'>";
                        
$subtipo=$row["id_subtipo"];    
        
$result_m=mysql_query("select * from t_marca WHERE id_subtipo=".$subtipo." ORDER BY id_marca",$linke);
   while(
$row_m mysql_fetch_array($result_m)) {
$desat=" ";
if (
$row_m["id_marca"]=='4'){ $desat.="<img src='images/marca-1.png'  height='30' align='center'  border='0'/>"; }
if (
$row_m["id_marca"]=='5'){ $desat.="<img src='images/marca-2.png'  height='30' align='center'  border='0'/>"; }
if (
$row_m["id_marca"]=='6'){ $desat.="<img src='images/marca-3.png'  height='30' align='center'  border='0'/>"; }
if (
$row_m["id_marca"]=='7'){ $desat.="<img src='images/marca-4.png'  height='30' align='center'  border='0'/>"; }
if (
$row_m["id_marca"]=='8'){ $desat.="<img src='images/marca-5.png'  height='30' align='center'  border='0'/>"; }
if (
$row_m["id_marca"]=='9'){ $desat.="<img src='images/marca-6.png'  height='30' align='center'  border='0'/>"; }
if (
$row_m["id_marca"]=='10'){ $desat.="<img src='images/marca-7.png'  height='30' align='center'  border='0'/>"; }
if (
$row_m["id_marca"]=='11'){ $desat.="<img src='images/marca-8.png'  height='30' align='center'  border='0'/>"; }
if (
$row_m["id_marca"]=='12'){ $desat.="<img src='images/marca-9.png'  height='30' align='center'  border='0'/>"; }
if (
$row_m["id_marca"]=='13'){ $desat.="<img src='images/marca-10.png'  height='30' align='center'  border='0'/>"; }
if (
$row_m["id_marca"]=='14'){ $desat.="<img src='images/marca-11.png'  height='30' align='center'  border='0'/>"; }
  echo
"<li><a href='detalle-producto.php?id_modelo=".$row_m["ma_name"]."'>".$desat."</a>";
  
$marca=$row_m["id_marca"];
  
$result_e=mysql_query("select * from t_modelos WHERE  id_subtipo=".$subtipo." AND id_marca=".$marca." ORDER BY id_modelo ;",$linke)  or die( "Error en query: $linke, el error  es: " mysql_error() );  
        while (
$row_e mysql_fetch_array($result_e)){
        if(
$marca==$row_e["id_marca"]){
echo
"<li><a href='detalle-producto.php?id_modelo=".$row_e["id_modelo"]."'>".$row_e["mo_titulo"]."</a>";
    } else {
echo
"";
    }}}
   echo
"</li></ul></div></li>";}
   
   echo
"</ul>
                </li>"
;}  
?>
El último llamado a modelo debería ser, si no hay modelo en la marca cuando el id_marca=id_marca(del modelo) entonces no debería aparecer. Pero no se traducirlo!