Ver Mensaje Individual
  #3 (permalink)  
Antiguo 04/12/2013, 08:14
Avatar de shake2427
shake2427
 
Fecha de Ingreso: julio-2011
Mensajes: 116
Antigüedad: 12 años, 9 meses
Puntos: 3
Respuesta: organizar registros al mostrarse

Cita:
Iniciado por jonni09lo Ver Mensaje
Pues es bastante simple, añade un contador.

Código PHP:
Ver original
  1. $contador = 0;
  2. echo "<table><tr>"; //aqui abres un tr
  3. while(/*condicion*/){
  4.     $contador++;
  5.     /*echo td*/
  6.     if($contador % 3 == 0){
  7.         echo "</tr><tr>";
  8.         $contador = 0;
  9.     }
  10. }
  11. echo "</tr></table>"; //cierras table y el tr

Algo así

Saludos

ya me funciono, el codigo completo quedaria asi, por si a alguiente le interesa
Código PHP:
Ver original
  1. <tr>
  2.         <td>
  3. <?
  4.     $contador = 0;
  5.     echo "<table cellpadding='10' cellspacing='0' align='center' border='0'><tr>"; //inicio tabla
  6.     while($infoproductoslist = $mtdlistproductos->fetch()){
  7.         $contador++;
  8. ?>     
  9.         <td align="center" onclick="javascript:window.location.href='detalle_producto.php?prodid=<? echo trim(base64_encode($infoproductoslist['productoID'])) ?>'" style="cursor: pointer">
  10.        <table cellpadding="0" cellspacing="0" width="100%" class="tablaproducto">
  11.     <tr>
  12.         <td style="background-color:#FEFEFE" align="center" colspan="2">
  13.         <img src="images/1.jpg" width="260" height="250" />
  14.         </td>
  15.     </tr>
  16.         <tr>
  17.             <td style="background-color:#F6F6F6; height:40px;font-family:Verdana, Geneva, sans-serif; font-size:13px; color:#999;padding-left:10px; font-weight:bold" colspan="2">
  18.                 <? echo  $infoproductoslist['producto']?>
  19.             </td>
  20.         </tr>  
  21.             <tr style="background-color:#FFFFFF;height:40px">
  22.                 <td style="font-family:Verdana, Geneva, sans-serif; font-size:13px; color:#999; padding-left:10px; font-weight:bold" width="50%">
  23.                 $ 306,000 f
  24.                 </td>
  25.                     <td align="center">
  26.                     <a href="detalle_producto.php?prodid=<? echo trim(base64_encode($infoproductoslist['productoID'])) ?>" style="font-family:Verdana, Geneva, sans-serif; font-size:14px; color:#060; text-decoration:none; text-align:center; font-weight:bold">Ver Mas</a>
  27.                     </td>
  28.             </tr>
  29. </table>
  30.         </td>
  31. <?        
  32.         if($contador % 4 == 0){
  33.             echo "</tr><tr>";
  34.             $contador = 0;
  35.         }
  36.     }
  37.     echo "</tr></table>"; //cierro tabla y tr
  38. ?>
  39.         </td>
  40.     </tr>

muchas gracias jonni09lo