Ver Mensaje Individual
  #7 (permalink)  
Antiguo 18/06/2011, 10:01
CristianVoltx
 
Fecha de Ingreso: febrero-2008
Mensajes: 9
Antigüedad: 16 años, 2 meses
Puntos: 0
Respuesta: Crear Tabla de una consulta con variable de usuario en PHP

Ya lo solucione. la consulta se hace de la siguiente forma:

<?php
include("conexion.php");
mysql_query("SET @total:=0");
$rst_ingresos=mysql_query("SELECT cuenta, fecha, debe , haber, @total:= debe - haber + @total as Saldo FROM mayor",$conexion);
$num_registros=mysql_num_rows($rst_ingresos);
if ($num_registros==0)
{
echo "No se han encontrado usuarios para mostrar";
mysql_close($conexion);
exit();
}
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
<style type="text/css">
#h1 {
text-align: center;
}
.H_3 {
font-weight: bold;
color: #333;
font-size: 12px;
}
.datos_tabla {
font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
font-size: 12px;
}
#cabecera_tabla {
font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
}
</style>
</head>

<body>
<table width="1080" border="0">
<tr>
<th colspan="5" scope="col">ULTIMOS MOVIMIENTOS</th>
</tr>
<tr>
<td colspan="5" id="h1">La informacion contenida aqui es a modo de prueba.</td>
</tr>
<tr class="H_3" id="cabecera_tabla">
<td width="82" bgcolor="#999999">CUENTA</td>
<td width="84" bgcolor="#999999">FECHA</td>
<td width="58" bgcolor="#999999">HABER</td>
<td width="89" bgcolor="#999999">DEBE</td>
<td width="109" bgcolor="#999999">SALDO</td>
</tr>

<?php
while ($fila=mysql_fetch_array($rst_ingresos))
{
?>
<tr bgcolor="#CCCCCC" class="datos_tabla">
<td><?php echo $fila[0];?></td>
<td><?php echo $fila[1];?></td>
<td><?php echo $fila[2];?></td>
<td><?php echo $fila[3];?></td>
<td><?php echo $fila[4];?></td>
</tr>
<?php
}
?>
</table>
</body>
</html>