combobox
Publicado por el albanés (1058 intervenciones) el 13/11/2011 03:19:55
necesito una ayuda con un combobox en un codigo que estoy desarrollando y se me ha hecho un poco engorroso, el asunto es que cuando intento que guarde un registro no lo hace. el dato que llevo del combo no actualiza la base datos, la pregunta es: ¿que debo pasar por el post el name del combo o la variable que recorre el WHILE?
adjunto el codigo en negrita:
<?php
$connect = pg_connect("host=localhost port=5432 dbname=administra user=postgres password=1234");
$diarios = "SELECT * FROM diario ORDER BY descripcion";
?>
<!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'>
<?php echo" <tr>
<td ALIGN='right' class='sr' >Gasto:</td>
<td><select name='cmbogasto'><option value='0' selected>Seleccione...";
$diarios = @pg_query($connect,$diarios);
WHILE($select2 = @pg_fetch_array($diarios)){
// $cCodigo = $select2['codigo'];
$descrip = $select2['descripcion'];
echo "<OPTION VALUE=$cCodigo>$descrip</OPTION>";
}
?>
</select></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 echo"<table align='center' border='1' bordercolor='#00CC99' bgcolor='#99CC00'>
<tr>
<th width='100' align='center'>Gasto
<th width='20' align='center'>Monto
<th width='20' align='center'>Fecha
</tr></table>";
?>
<?php
$todosgastos = "SELECT * FROM gastos ORDER BY fecha";
$seleccionados = @pg_query($connect,$todosgastos);
$total = 0;
while($select2 = @pg_fetch_array($seleccionados)):
$articulo = $select2['codigo'];
$descripcion = $select2['descripcion'];
$monto = $select2['monto'];
$fecha = $select2['fecha'];
echo"<table align='center' border='1' bordercolor='#FFCC99'>
<tr class='sr'>
<td width='30' align='center'><a href='modificar.php?art=$articulo' title='Modificar el gasto'>$articulo
<td width='110'>$descripcion
<td width='30' align='right'>$monto
<td width='30' align='right'>$fecha
<td width='30' style='font-size:10px;'><a href='eliminagasto.php?cod=$articulo'
onClick='return confirm(\"¿Está Seguro de Eliminar este Registro?\");'
<img src='img/equis.gif' title='Eliminar' heigth='25' width='25'></a></td>
</tr></table>";
$total +=$monto;
$ntotal = number_format($total,2,',','.');
endwhile;
$dtotal = "SELECT COUNT(*) AS tot FROM gastos";
$totgas = @pg_query($connect,$dtotal);
while($select1 = @pg_fetch_array($totgas)):
$gasto = $select1['tot'];
echo"<table align='center' border='1' bordercolor='#FFCC99'>
<tr class='sr'>
<td width='150' style='color:#000000'>Cantidad de Gastos
<td width='150' align='right'>$gasto
</tr></table>";
endwhile;
echo "<br><table align='center' border='1' bordercolor='#FFCC99' bgcolor='#99CC00'>
<tr class='sr'>
<td width='150' style='color:#000000'>Total
<td width='150' align='right'>$ntotal
</tr></table>";
?>
</form>
</body>
</html>
adjunto el codigo en negrita:
<?php
$connect = pg_connect("host=localhost port=5432 dbname=administra user=postgres password=1234");
$diarios = "SELECT * FROM diario ORDER BY descripcion";
?>
<!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'>
<?php echo" <tr>
<td ALIGN='right' class='sr' >Gasto:</td>
<td><select name='cmbogasto'><option value='0' selected>Seleccione...";
$diarios = @pg_query($connect,$diarios);
WHILE($select2 = @pg_fetch_array($diarios)){
// $cCodigo = $select2['codigo'];
$descrip = $select2['descripcion'];
echo "<OPTION VALUE=$cCodigo>$descrip</OPTION>";
}
?>
</select></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 echo"<table align='center' border='1' bordercolor='#00CC99' bgcolor='#99CC00'>
<tr>
<th width='100' align='center'>Gasto
<th width='20' align='center'>Monto
<th width='20' align='center'>Fecha
</tr></table>";
?>
<?php
$todosgastos = "SELECT * FROM gastos ORDER BY fecha";
$seleccionados = @pg_query($connect,$todosgastos);
$total = 0;
while($select2 = @pg_fetch_array($seleccionados)):
$articulo = $select2['codigo'];
$descripcion = $select2['descripcion'];
$monto = $select2['monto'];
$fecha = $select2['fecha'];
echo"<table align='center' border='1' bordercolor='#FFCC99'>
<tr class='sr'>
<td width='30' align='center'><a href='modificar.php?art=$articulo' title='Modificar el gasto'>$articulo
<td width='110'>$descripcion
<td width='30' align='right'>$monto
<td width='30' align='right'>$fecha
<td width='30' style='font-size:10px;'><a href='eliminagasto.php?cod=$articulo'
onClick='return confirm(\"¿Está Seguro de Eliminar este Registro?\");'
<img src='img/equis.gif' title='Eliminar' heigth='25' width='25'></a></td>
</tr></table>";
$total +=$monto;
$ntotal = number_format($total,2,',','.');
endwhile;
$dtotal = "SELECT COUNT(*) AS tot FROM gastos";
$totgas = @pg_query($connect,$dtotal);
while($select1 = @pg_fetch_array($totgas)):
$gasto = $select1['tot'];
echo"<table align='center' border='1' bordercolor='#FFCC99'>
<tr class='sr'>
<td width='150' style='color:#000000'>Cantidad de Gastos
<td width='150' align='right'>$gasto
</tr></table>";
endwhile;
echo "<br><table align='center' border='1' bordercolor='#FFCC99' bgcolor='#99CC00'>
<tr class='sr'>
<td width='150' style='color:#000000'>Total
<td width='150' align='right'>$ntotal
</tr></table>";
?>
</form>
</body>
</html>
Valora esta pregunta


0