Ver Mensaje Individual
  #6 (permalink)  
Antiguo 30/08/2011, 21:23
Avatar de emprear
emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 9 meses
Puntos: 1567
Respuesta: posicionar <td>

Podés usar esto


Código PHP:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <title>titulo</title>
  6. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  7. <style type="text/css">
  8. table td {
  9. border: solid 1px #000;
  10. border-spacing: 2px;
  11. }
  12. table tr td.sinborde {
  13. border: none;
  14. border-spacing: 0px;
  15. }
  16. </style>
  17. </head>
  18. <body>
  19. <?php
  20. $sqlhostname = "localhost";
  21. $login = "xxx";
  22. $password = "@xxx";
  23. $base = "xxxx";
  24.  
  25. $db_connect = mysql_connect($sqlhostname,$login,$password);
  26. $base_selection = mysql_select_db($base,$db_connect);
  27.  
  28. $query = "SELECT fecha FROM msm";
  29. $req = mysql_query($query);
  30.  
  31. if (!$req)
  32. { echo "<B>Error ".mysql_errno()." :</B> ".mysql_error()."";
  33. exit; }
  34. $res = mysql_num_rows($req);
  35.  
  36. if ($res == 0){
  37. echo "<center><b>sin resultados</b></center>";
  38. }else{
  39. $celdasporfila = 5;
  40. $resto = $res%$celdasporfila;
  41. echo "<table>\n<tr>\n";
  42. $x = 1;
  43. while($fila = mysql_fetch_array($req)){
  44. $fecha = $fila['fecha'];
  45.                       echo "<td>$fecha</td>\n";
  46.                       if($x == $celdasporfila){
  47.                       echo "</tr>\n<tr>";
  48.                       $x = 0;
  49.                       }                    
  50. $x++;
  51.     }
  52. }
  53.  if($resto != 0){
  54. echo "</tr>";
  55. }else{
  56. echo "\n<td class='sinborde' colspan='$celdasporfila'><!-- sin contenido --></td></tr>\n";
  57. }
  58. echo "</table>";
  59. ?>
  60. </body>
  61. </html>

Lo unico que tenes que indicar es el valor de la variable
$celdasporfila, en el caso de que el numero de celdas por fila respecto del numero de registros sea un cociente exacto, se te genera una fila adicional sin datos, que como se observa , se la puede formatear con css para quitarle el borde.
se puede elaborar un poco más. pero asi te genera un xhtml válido

Saludos
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.