I have two tables:
Personal: cedula, rango_id
Ranges: range_id, range (field with range description)
I would like you to modify the staff where your rank is selected your ID would not appear, like, 1 2 3 4, but the description that each one has in the table would appear.
I have the following code, but I do not know how to show it. Any ideas to do this?
<script>
function confirmSav()
{
var agree=confirm("¿Desea modificar este registro? ");
if (agree)
return true ;
else
return false ;
}
</script>
<script>
function confirmDel()
{
var agree=confirm("¿Desea eliminar este registro? ");
if (agree)
return true ;
else
return false ;
}
</script>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="/sino.js"></script>
<title> </title>
</head>
<body>
<form method = "POST" action = "">
<h1 align ="center">Bienvenido</h1>
<a href ="index.html"><ol>Pagina Principal</ol></a>
<a href ="registrar.php"><ol>Registrar</ol></a>
<a href ="listado.php"><ol>Listado</ol></a>
<a href ="Sancion.php"><ol>Sancion</ol></a>
<h1>Listado<br></h1>
<?php
include "conexion.php";
global $cone;
$contador = 0;
$registros=mysqli_query($cone,"select * from personal");
while ($reg = mysqli_fetch_array($registros))
{
$contador=$contador+1;
echo $contador."<br>";
echo "NOMBRE: ".$reg['nombre']."<br>";
echo "APELLIDO: ".$reg['apellido']."<br>";
echo "CEDULA: ".$reg['cedula']."<br>";
$registros=mysqli_query($cone,"select * from personal");
$sql =mysqli_query($cone,"SELECT a.cedula, b.rango_id, b.rango
FROM personal a
LEFT JOIN rangos b ON a.rango_id = b.id_rango
ORDER BY a.cedula ASC");
$reg = mysqli_fetch_array($registros);
echo "RANGO: ".$reg['rango_id']."<br>";
echo "<a onClick='return confirmSav();' href=actualizar.php?cedula=".$reg['cedula']." >editar<a/>"."<br>";
echo "<a onClick='return confirmDel();' href=procesar3.php?cedula=".$reg['cedula']." >eliminar<a/>"."<br>";
echo "<br>";
echo "<br>";
}
?>
</body>
</html>
Note, I do not know if I should add this line to the code:
$sql =mysqli_query($cone,"SELECT a.cedula, b.rango_id, b.rango
FROM personal a LEFT JOIN rangos b ON a.rango_id = b.id_rango
ORDER BY a.cedula ASC");
$sql2 = mysqli_fetch_array($sql);
echo "RANGO: ".$sql2['rango']."<br>";