Modificar formulario
Publicado por FJLG87 (1 intervención) el 06/05/2012 13:47:34
Hola buenas, mi problema es que imprimo por pantalla una tabla con todos los registros de la base de datos, para seleccionar uno y modificar este, el problemas es que seleccione registro que seleccione, siempre me muestra el ultimo registro. Es decir me manda el ultimo cif del ultimo registro a la pagina gestion_modificar_compania.php. Aqui os dejo el codigo fuente, espero me podais ayudar. Muchas gracias.
Este es el archivo modificar_compania.php
<?php
include("conectar.php");
$conexion=mysql_connect($servidor,$usuario,$pass);
mysql_select_db($database,$conexion);
$QUERY="SELECT * FROM companias order by cif asc";
$resultado=mysql_query($QUERY) or die("Error: ".mysql_error());
if(mysql_num_rows($resultado) > 0){
?>
<FORM METHOD="POST" ACTION="gestion_modificar_compania.php">
<table widht="600" height="30" border="1" align="center" cellpading="5" cellspacing="0" text="black">
<tr>
<td> <center> <font face="verdana"> <b> CIF </b> </font> </center> </td>
<td> <center> <font face="verdana"> <b> Nombre </b> </font> </center> </td>
<td> <center> <font face="verdana"> <b> Telefono </b> </font> </center> </td>
<td> <center> <font face="verdana"> <b> Fax </b> </font> </center> </td>
<td> <center> <font face="verdana"> <b> Correo </b> </font> </center> </td>
</tr>
<?
while($row=mysql_fetch_array($resultado)) {
echo "<tr>";
echo '<td widht="600" height="30" align="center">'.$row['cif']."-".$row['letra'].'</td>';
echo '<td widht="600" height="30" align="center">'.$row['nombre'].'</td>';
echo '<td widht="300" height="30" align="center">'.$row['telefono'].'</td>';
echo '<td widht="300" height="30" align="center">'.$row['fax'].'</td>';
echo '<td widht="300" height="30" align="center">'.$row['correo'].'</td>';
?>
<td>
<INPUT TYPE="hidden" name="cif" value="<?echo $row['cif'];?>">
<INPUT TYPE="SUBMIT" value="MODIFICAR">
</td> </tr>
<?
} }
else{
?>
<center> <h2> ERROR: No hay Aseguradoras registradas para listar. Introduzca una Aseguradora. </h2> </center>
<?
}
mysql_close();
?>
</table> </form> </body> </html>
Este es el archivo modificar_compania.php
<?php
include("conectar.php");
$conexion=mysql_connect($servidor,$usuario,$pass);
mysql_select_db($database,$conexion);
$QUERY="SELECT * FROM companias order by cif asc";
$resultado=mysql_query($QUERY) or die("Error: ".mysql_error());
if(mysql_num_rows($resultado) > 0){
?>
<FORM METHOD="POST" ACTION="gestion_modificar_compania.php">
<table widht="600" height="30" border="1" align="center" cellpading="5" cellspacing="0" text="black">
<tr>
<td> <center> <font face="verdana"> <b> CIF </b> </font> </center> </td>
<td> <center> <font face="verdana"> <b> Nombre </b> </font> </center> </td>
<td> <center> <font face="verdana"> <b> Telefono </b> </font> </center> </td>
<td> <center> <font face="verdana"> <b> Fax </b> </font> </center> </td>
<td> <center> <font face="verdana"> <b> Correo </b> </font> </center> </td>
</tr>
<?
while($row=mysql_fetch_array($resultado)) {
echo "<tr>";
echo '<td widht="600" height="30" align="center">'.$row['cif']."-".$row['letra'].'</td>';
echo '<td widht="600" height="30" align="center">'.$row['nombre'].'</td>';
echo '<td widht="300" height="30" align="center">'.$row['telefono'].'</td>';
echo '<td widht="300" height="30" align="center">'.$row['fax'].'</td>';
echo '<td widht="300" height="30" align="center">'.$row['correo'].'</td>';
?>
<td>
<INPUT TYPE="hidden" name="cif" value="<?echo $row['cif'];?>">
<INPUT TYPE="SUBMIT" value="MODIFICAR">
</td> </tr>
<?
} }
else{
?>
<center> <h2> ERROR: No hay Aseguradoras registradas para listar. Introduzca una Aseguradora. </h2> </center>
<?
}
mysql_close();
?>
</table> </form> </body> </html>
Valora esta pregunta


0