Foros del Web » Programando para Internet » PHP »

Listar horizontal

Estas en el tema de Listar horizontal en el foro de PHP en Foros del Web. Saludos... estoy haciendo un catalogo donde me deberian listar horizontalmente los articulos... a 3 por linea pero no me lo esta haciendo... quisiera saber si ...
  #1 (permalink)  
Antiguo 10/07/2008, 09:29
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 7 meses
Puntos: 28
Listar horizontal

Saludos... estoy haciendo un catalogo donde me deberian listar horizontalmente los articulos... a 3 por linea pero no me lo esta haciendo... quisiera saber si alguien ve el error...

Código PHP:
<?php include('conect.php');

$n_filas=3;

$fotos = array();

$sql="SELECT * FROM productos ORDER BY id ASC";
$sql_exec=mysql_query($sql) or die( "[ERROR] Query: $sql, error: " mysql_error() );
$cuenta=mysql_num_rows($sql_exec);    

function 
imagengrande() 

window.open("verimagen.php?imagen=/iamges2/<?=$imagen;?>""""width=450,height=300"); 
}
    
/*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);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0014)about:internet -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>GRUPO ALBARRACIN :::...</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">td img {display: block;}body {
    background-color: #EFF0D0;
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
}
</style>
<!--Fireworks CS3 Dreamweaver CS3 target.  Created Wed Jul 09 11:03:10 GMT-0400 2008-->
</head>
<body>
<table width="737" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<!-- fwtable fwsrc="index2.png" fwpage="inmuebles" fwbase="inmuebles.jpg" fwstyle="Dreamweaver" fwdocid = "136311868" fwnested="0" -->
  <tr>
   <td><img src="images/spacer.gif" width="8" height="1" border="0" alt="" /></td>
   <td><img src="images/spacer.gif" width="42" height="1" border="0" alt="" /></td>
   <td><img src="images/spacer.gif" width="6" height="1" border="0" alt="" /></td>
   <td><img src="images/spacer.gif" width="121" height="1" border="0" alt="" /></td>
   <td><img src="images/spacer.gif" width="4" height="1" border="0" alt="" /></td>
   <td><img src="images/spacer.gif" width="7" height="1" border="0" alt="" /></td>
   <td><img src="images/spacer.gif" width="44" height="1" border="0" alt="" /></td>
   <td><img src="images/spacer.gif" width="22" height="1" border="0" alt="" /></td>
   <td><img src="images/spacer.gif" width="1" height="1" border="0" alt="" /></td>
   <td><img src="images/spacer.gif" width="180" height="1" border="0" alt="" /></td>
   <td><img src="images/spacer.gif" width="44" height="1" border="0" alt="" /></td>
   <td><img src="images/spacer.gif" width="23" height="1" border="0" alt="" /></td>
   <td><img src="images/spacer.gif" width="50" height="1" border="0" alt="" /></td>
   <td><img src="images/spacer.gif" width="130" height="1" border="0" alt="" /></td>
   <td><img src="images/spacer.gif" width="12" height="1" border="0" alt="" /></td>
   <td><img src="images/spacer.gif" width="32" height="1" border="0" alt="" /></td>
   <td><img src="images/spacer.gif" width="11" height="1" border="0" alt="" /></td>
   <td><img src="images/spacer.gif" width="1" height="1" border="0" alt="" /></td>
  </tr>

  <tr>
   <td colspan="17"><img name="menu" src="images/menu.jpg" width="737" height="421" border="0" id="menu" alt="" /></td>
   <td><img src="images/spacer.gif" width="1" height="421" border="0" alt="" /></td>
  </tr>
  <tr>
   <td colspan="17"><img name="inmuebles_r2_c1" src="images/inmuebles_r2_c1.jpg" width="737" height="6" border="0" id="inmuebles_r2_c1" alt="" /></td>
   <td><img src="images/spacer.gif" width="1" height="6" border="0" alt="" /></td>
  </tr>
  <tr>
   <td colspan="17"><img name="linea_menu_bot" src="images/linea_menu_bot.jpg" width="737" height="36" border="0" id="linea_menu_bot" alt="" /></td>
   <td><img src="images/spacer.gif" width="1" height="36" border="0" alt="" /></td>
  </tr>
  <tr>
   <td colspan="4"><img name="nuevos_titu" src="images/nuevos_titu.jpg" width="177" height="65" border="0" id="nuevos_titu" alt="" /></td>
   <td colspan="9" rowspan="2" bgcolor="#FFFFFF">&nbsp;</td>
   <td colspan="4"><img name="inmuebles_titu" src="images/inmuebles_titu.jpg" width="185" height="65" border="0" id="inmuebles_titu" alt="" /></td>
   <td><img src="images/spacer.gif" width="1" height="65" border="0" alt="" /></td>
  </tr>
  <tr>
   <td colspan="4">&nbsp;</td>
   <td colspan="4">&nbsp;</td>
   <td><img src="images/spacer.gif" width="1" height="43" border="0" alt="" /></td>
  </tr>
  <tr>
   <td rowspan="23"><img name="inmuebles_r6_c1" src="images/inmuebles_r6_c1.jpg" width="8" height="1648" border="0" id="inmuebles_r6_c1" alt="" /></td>
   <td colspan="15" rowspan="23" valign="top" bgcolor="#DBDCA0"><table width="100%" border="0" cellspacing="0" cellpadding="0">
     <tr>
       <td><?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['img'];
                
                
//aqui deberia dibujar la tabla pero como?
                
echo "<td height='80' width='53' border='0' ><a href=# onClick=\"window.open('verimagen.php?id=".$row['id']."; ','verimagen', 'width=530,height=470'); return false;\"><img src='images2/".$row['imgprinc']."' width='125' height='160' border='0'/></a></td><tr><td>".$row['titulo']."</td><tr><td>".$row['descripcion']."</td>";
                
$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>'?>
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #2 (permalink)  
Antiguo 10/07/2008, 09:36
Avatar de hulray  
Fecha de Ingreso: septiembre-2006
Mensajes: 630
Antigüedad: 17 años, 7 meses
Puntos: 3
Respuesta: Listar horizontal

prueba con este <hr> ese te crea una linea horizontal
  #3 (permalink)  
Antiguo 10/07/2008, 09:48
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 7 meses
Puntos: 28
Respuesta: Listar horizontal

hr en donde??? ...

recuerda q el codigo esta diseñado para q me redibuje todo lo q esta dentro de el echo
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #4 (permalink)  
Antiguo 10/07/2008, 10:12
Avatar de hulray  
Fecha de Ingreso: septiembre-2006
Mensajes: 630
Antigüedad: 17 años, 7 meses
Puntos: 3
Respuesta: Listar horizontal

Dime, como tiene que quedar mas o menos, una linea cada 3 datos?

o una linea por dato?
  #5 (permalink)  
Antiguo 10/07/2008, 10:12
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 7 meses
Puntos: 28
Respuesta: Listar horizontal

asi deberia quedar
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #6 (permalink)  
Antiguo 10/07/2008, 13:19
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 7 meses
Puntos: 28
Respuesta: Listar horizontal

nadie ve mi error???
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #7 (permalink)  
Antiguo 11/07/2008, 07:53
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 7 meses
Puntos: 28
Respuesta: Listar horizontal

escribo otra vez en el tema para reubicarlo pues aun no consigo mi error... sera q alguien lo ve?? :(
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #8 (permalink)  
Antiguo 11/07/2008, 08:08
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 10 meses
Puntos: 2135
Respuesta: Listar horizontal

Hola T4keOveR,

Tu error es en la parte de HTML, te recomendaría que limpiaras tu código ya que tu HTML esta muy anidado y es probable que por ahí este tu error, lo mejor es primero codificar la plantilla y luego darle el dinamismo necesario con PHP.

Saludos.
  #9 (permalink)  
Antiguo 11/07/2008, 08:15
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 7 meses
Puntos: 28
Respuesta: Listar horizontal

ok GatorV gracias... lo hare y t cuento
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #10 (permalink)  
Antiguo 11/07/2008, 09:23
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 7 meses
Puntos: 28
Respuesta: Listar horizontal

aun sigue.. lo modifico y modifico y me lista vertical... no se si sera algun error en la forma d llemar las tablas o las celdas dentro del echo sera q hay alguna manera diferente???

Código PHP:
<?php include('conect.php');

// Variables de Configuración -----------------------------------
// Define el numero de Filas
$n_filas=3;

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

$fotos = array();
        
$sql="SELECT * FROM productos ORDER BY id ASC";
mysql_select_db ('connect');
    
$sql_exec=mysql_query($sql);

$tottal=113;
// ------------------------------------------------------------------------------------------------------------------
$vert=$tottal/$n_filas;
$vert=round($vert);

?>
<link href="css/estilo.css" rel="stylesheet" type="text/css" />

<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr>
    <td width="100%" height="130" align="center"><table width="100%" height="130" border="0" align="center" cellpadding="0" cellspacing="4">
        <table width="224" border="0" cellspacing="0" cellpadding="0">
 
        <?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['imgprinc'];
                
                echo 
"<td height='214' width='224' colspan='2' bgcolor='#000000'>prueba</td>
  </tr>
  <tr>
    <td width='180' height='78' bgcolor='#E8E7C1'>"
.$row['titulo']."</td>
    <td width='44'>"
.$row['imgprinc']."</td>
  </tr>
  <tr>
    <td height='96' colspan='2'>hola</td>
  </tr>
"
;
            
                
$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 '</table>';
                    } 
            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>';
        
?>
        </table>
    <p>&nbsp;</p></td>
  </tr>
</table>
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #11 (permalink)  
Antiguo 11/07/2008, 11:12
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 7 meses
Puntos: 28
Respuesta: Listar horizontal

antes lo hacia con un solo item y me funcionaba... lo hacia asi
Código PHP:
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr>
    <td width="100%" height="130" align="center"><table width="100%" height="130" border="0" align="center" cellpadding="0" cellspacing="4">
        
        <?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['imagen'];
                
                echo 
"<td height='100' width='100' border='0' class='marronlink' ><a href='ficha_prod.php?id=".$row['id']."'><img src='imgprod/".$row['imagen']."' width='90 height='90' border='0'/></a><br>";echo "<p class='marronlink'><a href='ficha_prod.php?id=".$row['id']."'>".$row['nombre']. "</a></p><br><br>";
            
                
$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>';
        
?>
fijense q solo dibujo un td en este codigo.. pero en el q estoy desarrollando ahorita no me sale!!!
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #12 (permalink)  
Antiguo 11/07/2008, 13:52
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 7 meses
Puntos: 28
Respuesta: Listar horizontal

bueno solucionado
Código PHP:
<?php include('conect.php');

// Variables de Configuración -----------------------------------
// Define el numero de Filas
$n_filas=3;

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

$fotos = array();
        
$sql="SELECT * FROM productos ORDER BY id ASC";
mysql_select_db ('conect');
    
$sql_exec=mysql_query($sql);

$tottal=113;
// ------------------------------------------------------------------------------------------------------------------
$vert=$tottal/$n_filas;
$vert=round($vert);

?>
<link href="css/estilo.css" rel="stylesheet" type="text/css" />

<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->

       
 
        <?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['imgprinc'];
                
echo 
"
    <td align='center'>
    <table width='224' border='0' cellspacing='0' cellpadding='0'>
  <tr>
    <td colspan='2' height='214' bgcolor='#DCDBA0' align='center'>pruebas varias</td>
  </tr>
  <tr>
    <td>"
.$row['titulo']."</td>
    <td>"
.$row['imgprinc']."</td>
  </tr>
  <tr>
    <td colspan='2' align='center'>hola probando</td>
  </tr>
</table>
</td>
    
    
"
;
            
                
$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
"
        texto de que no hay
        "
;
        break 
1;}
            
            }
            
        
?>
</table>
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 16:13.