Comunidad de diseño web y desarrollo en internet online

Problema al mostrar tablas en php, otra vez :(

Citar            
MensajeEscrito el 04 Jul 2007 06:29 pm
Hola muchachos, tengo un problemita con una tabla en SQL y html, quiero mostrar algunos datos de una tabla MySQL en un objeto <table>, y los datos restantes en otro objeto <table>. Me explico:

Tengo este codigo para mostrar las tablas:

Código :

<table width="1612" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFF00" bgcolor="#996699">
    <tr class="simpleTextRed">
    <th>Ocupaci&oacute;n</th>
    <th>Sexo</th>
    <th>Proveedor</th>
    <th>Ciudad</th>
    <th>Pa&iacute;s</th>
    <th>Telefono m&oacute;bil</th>
    <th>Pin</th>
    <th>Correo Electr&oacute;co</th>
</tr>

  <tr>  <?php
/*while ($registro = mysql_fetch_array($tabla)) {*/
?>
   
    <td width="68"  bgcolor="#663366"><span class="style5">
      <?php  echo $registro['ocupacion']; ?>
    </span></td>
    <td width="31"  bgcolor="#663366"><span class="style5">
      <?php  echo $registro['sexo']; ?>
    </span></td>
    <td width="64"  bgcolor="#663366"><span class="style5">
      <?php  echo $registro['proveedor']; ?>
    </span></td>
    <td width="44"  bgcolor="#663366"><span class="style5">
      <?php  echo $registro['ciudad']; ?>
    </span></td>
   
-
  <?php  echo $registro['celular']; ?>
    </span></td>
    <td width="19" bgcolor="#663366"><span class="style5">
      <?php  echo $registro['pin']; ?>
    </span></td>
    <td width="111" bgcolor="#663366"><span class="style5">
      <?php  echo $registro['email']; ?>
    </span></td>
  </tr>
  <?php
}
?></table>


<table width="1612" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFF00" bgcolor="#996699">
  <tr class="simpleTextRed">
    <th>Usuario</th>
    
    <th>C&oacute;digo postal</th>
    
  </tr>

  <tr>  <?php
while ($registro = mysql_fetch_array($tabla)) {
?>
    <td width="50"  bgcolor="#663366"><span class="style5">
      <?php  echo $registro['usuario']; ?>
    </span></td>    
    <td width="86"  bgcolor="#663366"><span class="style5">
      <?php  echo $registro['codigo_postal']; ?>
    </span></td>
   
  </tr>
  <?php
}
mysql_free_result($tabla);
mysql_close($conexion);
?></table>




Pero me sale cualquier cosa, no se bien por donde encararlo. ¿alguna ayuda?
Gracias!

Por germanwasem

6 de clabLevel



Genero:Masculino  

Uruguay

firefox
Citar            
MensajeEscrito el 05 Jul 2007 02:27 pm

Código :

<table width="1612" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFF00" bgcolor="#996699">
    <tr class="simpleTextRed">
    <th>Ocupaci&oacute;n</th>
    <th>Sexo</th>
    <th>Proveedor</th>
    <th>Ciudad</th>
    <th>Pa&iacute;s</th>
    <th>Telefono m&oacute;bil</th>
    <th>Pin</th>
    <th>Correo Electr&oacute;co</th>
</tr>

  <?php
/*while ($registro = mysql_fetch_array($tabla)) {*/
?>
     <tr>
    <td width="68"  bgcolor="#663366"><span class="style5">
      <?php  echo $registro['ocupacion']; ?>
    </span></td>
    <td width="31"  bgcolor="#663366"><span class="style5">
      <?php  echo $registro['sexo']; ?>
    </span></td>
    <td width="64"  bgcolor="#663366"><span class="style5">
      <?php  echo $registro['proveedor']; ?>
    </span></td>
    <td width="44"  bgcolor="#663366"><span class="style5">
      <?php  echo $registro['ciudad']; ?>
    </span></td>
   
-
  <?php  echo $registro['celular']; ?>
    </span></td>
    <td width="19" bgcolor="#663366"><span class="style5">
      <?php  echo $registro['pin']; ?>
    </span></td>
    <td width="111" bgcolor="#663366"><span class="style5">
      <?php  echo $registro['email']; ?>
    </span></td>
  </tr>
  <?php
}
?></table>


<table width="1612" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFF00" bgcolor="#996699">
  <tr class="simpleTextRed">
    <th>Usuario</th>
    
    <th>C&oacute;digo postal</th>
    
  </tr>

  <?php
while ($registro = mysql_fetch_array($tabla)) {
?>  <tr>
    <td width="50"  bgcolor="#663366"><span class="style5">
      <?php  echo $registro['usuario']; ?>
    </span></td>    
    <td width="86"  bgcolor="#663366"><span class="style5">
      <?php  echo $registro['codigo_postal']; ?>
    </span></td>
   
  </tr>
  <?php
}
mysql_free_result($tabla);
mysql_close($conexion);
?></table>




No metias los <tr> en los bucles.

Por One

Claber

1488 de clabLevel

5 tutoriales

Genero:Masculino  

Programador Web

firefox
Citar            
MensajeEscrito el 05 Jul 2007 02:42 pm
U lo intentaré, claro, 'Table Row'... Gracias!

Por germanwasem

6 de clabLevel



Genero:Masculino  

Uruguay

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.