Ver Mensaje Individual
  #1 (permalink)  
Antiguo 07/01/2009, 14:46
Avatar de T4ke0veR
T4ke0veR
 
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Condicionar listado de productos

Saludos,
Hermanos tngo un listado de productos donde estos los divido por marcas pero quiero que si no tngo existencia d este productos en determinada marca tampoco me muestre la marca ni el logo, pues el me muestra la marca seguida de los productos que en ella existen, pero si no hay productos en esa marca no quiero q se muestre, si no q salte a la marca siguiente

aqui tengo mi codigo...

Código PHP:
<?php require_once('Connections/cersol.php'); 
include(
'connect.php');
?>
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  
$theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}
}

mysql_select_db($database_cersol$cersol);
$query_Recordset1 "SELECT * FROM marca_termicas";
$Recordset1 mysql_query($query_Recordset1$cersol) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 mysql_num_rows($Recordset1);

mysql_select_db($database_cersol$cersol);
$query_Recordset2 "SELECT * FROM imp_term";
$Recordset2 mysql_query($query_Recordset2$cersol) or die(mysql_error());
$row_Recordset2 mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 mysql_num_rows($Recordset2);
?>

 <table width="356" border="0" cellspacing="0" cellpadding="0">
  
  <tr>
    <td scope="col"><?php do { ?><?php if ($row_Recordset2['id_marca']!=0){ ?><table width="480" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td width="182" rowspan="2" align="left" valign="top"><table width="157" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><div align="left"><img src="logo/<?php echo $row_Recordset1['logo']; ?>" /></div></td>
            </tr>
        </table>
          </td>
        <td width="298" class="tituloMarca"><div align="left"><?php echo strtoupper($row_Recordset1['nombre']); ?></div></td>
      </tr>
      <tr>
        <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><?php 
        
// Variables de Configuraci&oacute;n -----------------------------------
// Define el numero de Filas
$n_filas=2;

//***************************************************************
@$type=$_REQUEST['tipe'];
//$cat=8;

$fotos = array();
        
$sql="SELECT * FROM imp_term WHERE id_marca=".$row_Recordset1['id']." and tipo = ".$type."";
mysql_select_db ('connect');
    
$sql_exec=mysql_query($sql);
    
    
/*while($row=mysql_fetch_assoc($sql_exec)){
            $tottal=mysql_affected_rows(); // Calculo el numero total de itms a listar
            }*/
$tottal=113;
// ------------------------------------------------------------------------------------------------------------------
$vert=$tottal/$n_filas;
$vert=round($vert); ?> 
              <?php 
        $a
=0;// Colocando el contador horizontal en 0
        
$i=1;// Colocando el contador vertical en 0
        
$w=0;//Colocando un contador para el mensaje de "No hay articulos en esta acategoria"
        
            
while($row=mysql_fetch_assoc($sql_exec)){
            
$w=w+1;
                if (
$a==0){
                echo 
'<tr>';
                }
                
$a=$a+1;
                
$fotos[$i.'-'.$a] = $row['nombre'];
                
                echo 
"<td width='180' height='15' border='0'><p align='left' class='marronlink'><a href='ficha_camioneta.php?id=".$row['id']."'>".$row['nombre']. "</a></p>";
            
                
$r=$a;// contador remanente para listar imagenes sin exceso
                
                    
if ($a >= $n_filas) {
                    
$a=0;// reiniciando el contador horizontal
                    
$i=$i+1;// aumentando el contador vertical
                    
echo '</tr>';
                    } 
            if (empty(
$row)) {
        echo
"<table width='0' border='0' align='center' cellpadding='0' cellspacing='0'>
          <tr>
            <td width='257'><div align='center'>No hay articulos en esta categoria </div></td>
          </tr>
        </table>
        "
;
        break 
1;}
            
            }
            
         echo 
'</td>'
        
?> </td>
          </tr>
        </table>
          <br /></td>
      </tr>
      <tr>
        <td colspan="2" align="center" valign="top">&nbsp;</td>
        </tr>
      <tr>
        <td colspan="2" align="center" valign="top">&nbsp;</td>
      </tr>
    </table>
          <?php } while ($row_Recordset1 mysql_fetch_assoc($Recordset1)); ?><?php }?></td>
  </tr>
  <tr>
    <td scope="col"></td>
  </tr>
</table>
  

  <p class="tituloQUIENES">
    <?php
mysql_free_result
($Recordset1);
?>
URL de muestra
http://cersolve.com/prueba/print_ord.php?tipe=2

Gracias
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...

Última edición por T4ke0veR; 07/01/2009 a las 14:54