Foros del Web » Programando para Internet » PHP »

Problema con tabla PHP

Estas en el tema de Problema con tabla PHP en el foro de PHP en Foros del Web. Hola!. Tengo esta tabla en PHP: Código PHP: <table id="order-history"> <thead> <tr> <th align="left"><a href="#" class="sort-link numeric"><span class="arrow">Pedido</span></a></th> <th align="left">Producto</th> <th>Cantidad</th> <th>Estado</th> </tr> </thead> <tbody> <tr class="parent-row" onclick=""> <td valign="top"><a href="#"> <?php  echo  $results_historial [ guid ...
  #1 (permalink)  
Antiguo 08/07/2011, 05:50
Avatar de Soir  
Fecha de Ingreso: marzo-2011
Mensajes: 40
Antigüedad: 13 años, 1 mes
Puntos: 1
Problema con tabla PHP

Hola!.

Tengo esta tabla en PHP:

Código PHP:
<table id="order-history">
<thead>
<tr>
<th align="left"><a href="#" class="sort-link numeric"><span class="arrow">Pedido</span></a></th>
<th align="left">Producto</th>
<th>Cantidad</th>
<th>Estado</th>
</tr>
</thead>
<tbody>
<tr class="parent-row" onclick="">
<td valign="top"><a href="#"><?php echo $results_historial[guid]; ?></a></td>

<td valign="top">
<strong data-service-id="null"><?php echo $results_historial[factura]; ?></strong>
</td>
<td valign="top" class="align-center"><?php echo $results_historial[cantidad]; ?></td>
<td valign="top" class="align-center status-success">
<?php echo $results_historial[estado]; ?>
</td>
</tr>
</tbody>
</table>
Que utiliza esta sentencia SQL:
Código:
$query_historial = db_query("SELECT guid, cantidad, factura, estado FROM historial WHERE id_cuenta = '".$user_check_accountid."' ORDER BY guid DESC LIMIT 10");
$results_historial = mysqli_fetch_array($query_historial);
Y el problema, es que yo en esa tabla, relacionada con mi cuenta tengo unos 25 datos... Pero en la tabla sólo se muestra 1.

Es decir, de los 25 datos que hay que se deberían mostrar, sólo se ve 1:



¿Cómo se podría solucionar?
Gracias ^^.
  #2 (permalink)  
Antiguo 08/07/2011, 05:54
Avatar de Eleazan  
Fecha de Ingreso: abril-2008
Ubicación: Ibiza
Mensajes: 1.879
Antigüedad: 16 años
Puntos: 326
Respuesta: Problema con tabla PHP

Te falta un bucle.

mysqli_fetch_array cada vez que lo usas, devuelve UNA linea de la tabla. el while podría ser algo así
Código PHP:
while($results_historial myqli_fetch_array($query_historial)) {
   
aqui_imprimo_un_tr

Y eso debería ir en medio de la tabla :) (después del header)


Y te quedaría algo así
(No te recomiendo copiar y pegar, sino hacerlo por ti mismo!)
Código PHP:
<table id="order-history">
<thead>
<tr>
<th align="left"><a href="#" class="sort-link numeric"><span class="arrow">Pedido</span></a></th>
<th align="left">Producto</th>
<th>Cantidad</th>
<th>Estado</th>
</tr>
</thead>
<tbody>
<?php
while($results_historial myqli_fetch_array($query_historial)) { ?>
<tr class="parent-row" onclick="">
<td valign="top"><a href="#"><?php echo $results_historial[guid]; ?></a></td>

<td valign="top">
<strong data-service-id="null"><?php echo $results_historial[factura]; ?></strong>
</td>
<td valign="top" class="align-center"><?php echo $results_historial[cantidad]; ?></td>
<td valign="top" class="align-center status-success">
<?php echo $results_historial[estado]; ?>
</td>
</tr>
<?php ?>
</tbody>
</table>
  #3 (permalink)  
Antiguo 08/07/2011, 07:18
Avatar de Soir  
Fecha de Ingreso: marzo-2011
Mensajes: 40
Antigüedad: 13 años, 1 mes
Puntos: 1
Respuesta: Problema con tabla PHP

Ahora no sale ningún dato...

No se que puede pasar.

Solucionado. Gracias ^^.

Última edición por Soir; 08/07/2011 a las 07:35

Etiquetas: mysql, tabla
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 01:07.