Good evening, I am looking for help with the following, I want to modify a record of a table in php, I have already managed to search for the records and show links to modify and delete using the following code:
<!doctype html>
<?php
$texto = '';
//Variable que contendrá el número de resgistros encontrados
$registros = '';
if($_POST){
$busquedanombre = trim($_POST['buscarnombre']);
$busquedaimo = trim($_POST['buscarimo']);
$busquedasiglas = trim($_POST['buscarsiglas']);
$busquedabandera = trim($_POST['buscarbandera']);
$entero = 0;
mysql_set_charset('utf8');
$sql = "SELECT * FROM buques WHERE NOMBRE LIKE '%" .$busquedanombre. "%' AND IMO LIKE '%" .$busquedaimo."%' AND SIGLAS LIKE '%" .$busquedasiglas. "%' AND BANDERA LIKE '%" .$busquedabandera. "%'" ;
$resultado = mysql_query($sql);
if (mysql_num_rows($resultado) > 0){
$registros = '<p>Hemos encontrado ' . mysql_num_rows($resultado) . ' registros </p>';
$texto .= '<table border=1 cellspacing=0 cellpadding=2 bordercolor=0e590d >';
$texto .= '<thead><tr><td width=210>Nombre del Buque</td><td width=65>IMO</td><td width=70>Siglas</td><td width=150>Bandera</td></tr></thead>';
while ($fila = mysql_fetch_assoc($resultado)){
//$texto .= '<table border=1 cellspacing=0 cellpadding=2 bordercolor=0e590d >';
$texto .= '<tr><td width=210>'.$fila['NOMBRE'].'</td>'; ;
$texto .= '<td width=65><font size ="3", color ="#095107">'.$fila['IMO'].'</font></td>';
$texto .= '<td width=70>'.$fila['SIGLAS'].'</td>';
$texto .= '<td width=150>'.$fila['BANDERA'].'</td>';
$texto .= '<td width=70><a href="modificar-buque.php?id='.$fila['IMO'].'">Modificar</a></td>';
$texto .= '<td width=25><a href="confirmar-eliminar-buque.php?id='.$fila['IMO'].'">Eliminar</a></td></tr>';
}
$texto .='</table>';
}else{
$texto = "No existen registros que coincidan con los parámetros de búsqueda.";
}
}
?>
<html>
<head>
<meta charset="utf-8">
<title>Buscar Buque</title>
</head>
<body>
<form method="POST" action="" onSubmit="return validarForm(this)">
<p>
<label for="buscarnombre">Nombre del buque:</label>
<input name="buscarnombre" type="search" id="buscarnombre">
</p>
<p>
<label for="buscarimo">IMO:</label>
<input type="number" name="buscarimo" id="buscarimo">
</p>
<p>
<label for="buscarsiglas">Siglas:</label>
<input type="search" name="buscarsiglas" id="buscarsiglas">
</p>
<p>
<label for="buscarbandera">Bandera:</label>
<select name="buscarbandera" id="buscarbandera">
<option value=" "> Seleccione una Bandera </option>
<option value=" Afganistán "> Afganistán </option>
<option value=" Akrotiri "> Akrotiri </option>
<option value=" Albania "> Albania </option>
<option value=" Alemania "> Alemania </option>
bla bla bla lista de paises
</select></p>
<p>
<input type="submit" value="Buscar" name="buscar">
</p>
</form>
<?php // Se muestran los resultados de la consulta, número de registros y contenido.
echo $registros;
echo $texto; ?>
<p><br>
</p>
</body></html>
Pressing the link to modify, link to the following page making the link with the record bearing the IMO identifier:
<!doctype html>
<?php
include('libreria/motor.php');
$v1 =$_GET['id'];
$v2 = $v1;
$query="select * from buques where IMO='$v2'";
$result=mysql_query($query);
$row=mysql_fetch_array($result);
?>
<html>
<head>
<meta charset="utf-8">
<title>Agregar Buque</title>
</head>
<body>
<form target="_self" autocomplete="on" method="post" action=""
name="BUQUE"> <label for="NOMBRE">Nombre:</label> <br>
<input autocomplete="on" maxlength="40" required name="NOMBRE" type="text" value="$row[NOMBRE]"><br>
<label for="IMO">IMO:</label> <br>
<input autocomplete="on" required name="IMO" type="number"><br>
<label for="SIGLAS">Siglas IMO:</label><br>
<input autocomplete="on" maxlength="10" required name="SIGLAS"type="text"><br>
<label for="BANDERA">Bandera:</label><br>
<select required name="BANDERA">
<option value=" "> Seleccione una Bandera </option>
<option value=" Afganistán "> Afganistán </option>
<option value=" Akrotiri "> Akrotiri </option>
<option value=" Albania "> Albania </option>
<option value=" Alemania "> Alemania </option>
bla bla bla lista de paises
</select>
<br>
<label for="PUERTOREG">Puerto de Registro:</label> <br>
<select required name="PUERTOREG">
<option value=" "> Seleccione un puerto de registro </option>
<option value=" Aachen "> Aachen </option>
<option value=" Aalesund "> Aalesund </option>
<option value=" Aarhus "> Aarhus </option>
<option value=" Abaco "> Abaco </option>
<option value=" Abakan "> Abakan </option>
<option value=" Abidjan "> Abidjan </option>
bla bla lista de puertos
</select>
<br>
<label for="EMAIL">e-Mail:</label> <br>
<input autocomplete="on" name="EMAIL" type="email"><br>
<label for="ESLORA">Eslora (LOA):</label><br>
<input autocomplete="on" required name="ESLORA" type="number" step="any"><br>
<label for="PUNTAL">Puntal (Depth Moulded):</label><br>
<input autocomplete="on" required name="PUNTAL" type="number" step="any"><br>
<label for="MANGA">Manga (Breadth Moulded):</label><br>
<input autocomplete="on" required name="MANGA" type="number" step="any"><br>
<label for="ARMADOR">Armador:</label><br>
<textarea required name="ARMADOR" wrap="soft"></textarea><br>
<label for="OPERADOR">Operador:</label><br>
<textarea required name="OPERADOR"></textarea><br>
<label for="TONBRUTO">Tonelaje Bruto:</label> <br>
<input autocomplete="on" required name="TONBRUTO" type="number" step="any"><br>
<label for="TONNETO">Tonelaje Neto:</label><br>
<input autocomplete="on" required name="TONNETO" type="number" step="any"><br>
<label for="CAPCARGA">Capacidad de carga (m³):</label><br>
<input autocomplete="on" required name="CAPCARGA" type="number" step="any"><br>
<br>
<input name="Enviar" id="Enviar" value="Enviar" type="submit"><br>
</form>
<p><br>
</p>
</body></html>
What I want to do is that the modification form brings the data of the selected record and shows it inside the form, so that the user only MODIFIES the information that he needs and then press send.
Thanks in advance.