eliminar registros
Publicado por zendi (1058 intervenciones) el 17/12/2009 20:12:29
estoy creando un codigo en php para eliminar unos registros desde un formulario pero no se eliminan si alguien me pudiera darme una luz. estoy utilizando DELETE
aqui esta el codigo:
SE LO AGRADEZCO DE ANTEMANO
<body>
<form action="listagastos.php" method="post">
<?php
echo"<table align='center' border='1' bordercolor='#00CC99' bgcolor='#99CC00'>
<tr>
<th width='100'>Código
<th width='200'>Descripción
</tr></table>";
$total = "SELECT * FROM gastos ORDER BY descripcion";
$ntotal = @pg_query($connect,$total);
while($ngastos = @pg_fetch_array($ntotal)):
$codigo = $ngastos['codigo'];
$descripcion = $ngastos['descripcion'];
echo"<table align='center' border='1' bordercolor='#FFCC99' bgcolor='#99CC00'>
<tr class='sr'>
<td width='50'>$codigo
<td width='200'>$descripcion
</tr>
</table>";
endwhile;
echo"<table align='center'>
<tr>
<td>
<input class='color1' type='submit' name='action' value='Eliminar'>
</td>
</tr>
</table>";
if (isset($_POST['action'])):
$connect2 = pg_connect("host=localhost port=5432 dbname=administracion user=postgres password=passsecret");
$eliminar = "DELETE FROM gastos";
@pg_query($eliminar,$connect2);
endif;
?>
</form>
</body>
</html>
aqui esta el codigo:
SE LO AGRADEZCO DE ANTEMANO
<body>
<form action="listagastos.php" method="post">
<?php
echo"<table align='center' border='1' bordercolor='#00CC99' bgcolor='#99CC00'>
<tr>
<th width='100'>Código
<th width='200'>Descripción
</tr></table>";
$total = "SELECT * FROM gastos ORDER BY descripcion";
$ntotal = @pg_query($connect,$total);
while($ngastos = @pg_fetch_array($ntotal)):
$codigo = $ngastos['codigo'];
$descripcion = $ngastos['descripcion'];
echo"<table align='center' border='1' bordercolor='#FFCC99' bgcolor='#99CC00'>
<tr class='sr'>
<td width='50'>$codigo
<td width='200'>$descripcion
</tr>
</table>";
endwhile;
echo"<table align='center'>
<tr>
<td>
<input class='color1' type='submit' name='action' value='Eliminar'>
</td>
</tr>
</table>";
if (isset($_POST['action'])):
$connect2 = pg_connect("host=localhost port=5432 dbname=administracion user=postgres password=passsecret");
$eliminar = "DELETE FROM gastos";
@pg_query($eliminar,$connect2);
endif;
?>
</form>
</body>
</html>
Valora esta pregunta


0