PHP - obtener cantidad de REGISTROS

 
Vista:

obtener cantidad de REGISTROS

Publicado por zendi (16 intervenciones) el 08/02/2010 17:25:49
tengo este codigo que crea un formulario donde aparecen unos gastos, y quisiera contar el numero de los gastos ¿que script sería oportuno? PREGUNTO ES EN ESTE FORO?
O EL DE PHP?

ESTE ES EL CODIGO DEL FORMULARIO
<?php
$connect = pg_connect("host=localhost port=5432 dbname=administracion user=postgres password=pass");
?>
<!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=iso-8859-1" />
<title>Gastos</title>
<style type="text/css">
.sr {
background-color: #FFFFCF;
color: #000000;
font-family: Arial;
font-size: 12px;
}
input.color1 {background-color: #00CC99; font-weight: bold; font-size: 12px; color: white;}
</style>
</head>
<body>
<?php
$hoy=date('d-m-Y');
?>
<form action="ingresagastos.php" method="POST">
<fieldset style='width:auto'><LEGEND>Gastos</LEGEND>
<table align='center'>
<tr>
<td class="sr" align='right' style="text-decoration:none">Descripción:</td>
<td class="sr"><input type="text" name="descripcion" size="50" maxlength="50" align="right"/></td>
</tr>
<tr>
<td class="sr" align='right' style="text-decoration:none">Monto:</td>
<td class="sr"><input type="text" name="monto" size="5" maxlength="5" align="right"/></td>
</tr>
<tr>
<td class="sr" align='right' style="text-decoration:none">Fecha:</td>
<td class="sr"><input type="text" value="<?php echo $hoy;?>" readonly=".F." name="fecha" size="10" maxlength="10" align="right"/></td>
</tr>
</table>
<table align="center">
<tr>
<td>
<input class="color1" type="submit" name="action" value="Guardar">
<input class="color1" type="reset" value="Deshacer">
</td>
</tr>
</table>
</fieldset>
<br />
<?php
$todosgastos = "SELECT * FROM gastos ORDER BY descripcion";
$seleccionados = @pg_query($connect,$todosgastos);
$total = 0;
while($select2 = @pg_fetch_array($seleccionados)):
$articulo = $select2['codigo'];
$descripcion = $select2['descripcion'];
$monto = $select2['monto'];
echo"<table align='center' border='1' bordercolor='#FFCC99'>
<tr class='sr'>
<td width='50'>$articulo
<td width='200'>$descripcion
<td width='50' align='right'>$monto
</tr></table>";
endwhile;
?>
</form>
</body>
</html>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder