Foros del Web » Programando para Internet » PHP »

Ayuuuda!!!! Como imprimir en una tabla multiples registro de historial

Estas en el tema de Ayuuuda!!!! Como imprimir en una tabla multiples registro de historial en el foro de PHP en Foros del Web. compañeros lo que necesito es imprimir una tabla de acuerdo al numero de registros asociados a un determinado ID este ID ya lo tengo dentro ...
  #1 (permalink)  
Antiguo 14/09/2010, 10:41
 
Fecha de Ingreso: julio-2010
Ubicación: mexico DF
Mensajes: 34
Antigüedad: 13 años, 8 meses
Puntos: 0
Pregunta Ayuuuda!!!! Como imprimir en una tabla multiples registro de historial

compañeros lo que necesito es imprimir una tabla de acuerdo al numero de registros asociados a un determinado ID este ID ya lo tengo dentro de un array
creo que podria ser con un while pero no me funciona solo me imprime el primer registro asociado al ID de mi array, esto me va a servir para que en una tabla me muestre el hitorial de pagos de un alumno, aqui muestro el codigo

Código PHP:
<?php require_once('Connections/cn.php'); ?>
<?php

$valor
=$_GET["ID"];
mysql_select_db($database_cn$cn);
$sql="select * from pagos where ID_alumno='$valor'  ";
$sql1="select * from alumnos where ID='$valor' ";

$r=mysql_query($sql);
$r2=mysql_query($sql1);
$res=mysql_fetch_array($r);
$res2=mysql_fetch_array($r2);

?>
con este codigo extraigo de mi BD e introduzco a un array, ahora mi tabla

Código HTML:
<table border="1">
  <tr style="background-color:#0099FF">
    <td valign="top" align="center" width="100"><strong>N° de pago</strong></td>
    <td valign="top" align="center" width="300"><strong>Nombre</strong></td>
    <td valign="top" align="center" width="200"><strong>Concepto</strong></td>
	<td valign="top" align="center" width="70"><strong>periodo</strong></td>
	<td valign"top" align="center" width="150"><strong>cantidad</strong></td>
	<td valign="top" align="center" width="100"><strong>N° de factura</strong></td>
	<td valign="top" align="center" width="80"><strong>Fecha</strong></td>
	<td valign="top" align="center" width="80"><strong>Hora</strong></td>
	<td valign="top" align="center" width="80"><strong>Funcion</strong></td>
    <tr>
	  <td><?php echo $res['ID']; ?></td>
      <td><?php echo $res2['nombre']; ?></td>
      <td><?php echo $res['conceptopago']; ?></td>
	  <td><?php echo $res['periodopago']; ?></td>
	  <td><?php echo $res['cantidad']; ?></td>
	  <td><?php echo $res['facorec']; ?></td>
	  <td><?php echo $res['fechapago']; ?></td>
	  <td><?php echo $res['hora']; ?></td>
	  <td width="55" align="center" valign="top">
	  <a href="adminpagos.php?ID=<?php echo $res2['ID'];?>" title="Regustrar Pago">
		<img src="pago.bmp" width="24" height="24" border="0"> 
	  </a>
	  </td> 
  </tr>
</table> 
EN DONDE IRIA EL CICLO PARA REPETIR LA IMPRESION DE REGISTROS CONTINUOS
  #2 (permalink)  
Antiguo 15/09/2010, 08:24
Avatar de Perr0  
Fecha de Ingreso: mayo-2005
Ubicación: Santiago de Chile, Chile
Mensajes: 676
Antigüedad: 18 años, 10 meses
Puntos: 79
Respuesta: Ayuuuda!!!! Como imprimir en una tabla multiples registro de historial

Hola Triste hombre

mira hay veces que tengo problemas con la compresión y en otras ocasiones con la mala redacción, tratare de darte una mano:

Código PHP:
Ver original
  1. <table border="1">
  2. <!--SE ELIMINARION CIERTOS ATRIBUTOS QUE <TH> DA POR DEFECTO
  3. SE AGREGA THEAD Y TBODY -->
  4.   <tr style="background-color:#0099FF">
  5.     <th valign="top" width="100">N° de pago</th>
  6.     <th valign="top" width="300">Nombre</th>
  7.     <th valign="top" width="200">Concepto</th>
  8.     <th valign="top" width="70">periodo</th>
  9.     <th valign="top" width="150">cantidad</th>
  10.     <th valign="top" width="100">N° de factura</th>
  11.     <th valign="top" width="80">Fecha</th>
  12.     <th valign="top" width="80">Hora</th>
  13.     <th valign="top" width="80">Funcion</th>
  14.   </tr><!-- ESTE TR NO ESTABA, AGREGADO POR Perr0 -->
  15. <?
  16. //ESTA PARTE TU SABES COMO CONECTAS
  17. require_once('Connections/cn.php');
  18. $valor=$_GET["ID"];
  19.  
  20. $cn=mysql_connect("localhost","root","");
  21. $conectar_bd=mysql_select_db($database_cn,$cn);
  22.  
  23. //CON ESTO TENEMOS UNA CONSULTA CON LAS DOS TABLAS
  24. $consulta="SELECT * FROM pagos INNER JOIN ID=ID_alumno WHERE ID_alumno='$valor'";
  25.  
  26. $query=mysql_query($consulta);
  27. while($res=mysql_fetch_assoc($query)){
  28.     print "<tr>";
  29.     print "<td>".$res['ID']."</td>";
  30.     print "<td>".$res['nombre']."</td>";
  31.     print "<td>".$res['conceptopago']."</td>";
  32.     print "<td>".$res['periodopago']."</td>";
  33.     print "<td>".$res['cantidad']."</td>";
  34.     print "<td>".$res['facorec']."</td>";
  35.     print "<td>".$res['fechapago']."</td>";
  36.     print "<td>".$res['hora']."</td>";
  37.     print "<td width=\"55\" valign=\"top\">
  38.     <a href=\"adminpagos.php?ID=$res['ID']\" title=\"Regustrar Pago\">
  39.     <img src=\"pago.bmp\" width=\"24\" height=\"24\" border=\"0\"></a></td>";
  40.     print "</tr>";
  41. }
  42.  
  43. ?>
  44. </table>

espero te sirva, la idea es armar bien el codigo y no estabas usando while para armar el bucle de la consulta,
se me olvido agregar thead y tbody, pero es cosa tuya

salu2

Etiquetas: historial, multiples, registro, tablas
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 03:11.