Greetings friends, I would like to know how to order a list that you create from a mysqli_fetch_array
.
Apart from this code I have a search engine, what I want is that the results of the search appear in a specific row, for example code number or name.
<?php
require ("datos_de_acceso.php");
$conexion=mysqli_connect($db_host,$db_usuario,$db_contra);
if (mysqli_connect_errno()){
echo "Fallo al conectar con la BBDD";
exit();
}
mysqli_set_charset($conexion, "utf-8");
mysqli_select_db($conexion, $db_nombre) or die ("No se encuentra la base de datos");
mysqli_query($conexion, "SET NAMES 'utf8'");
$busqueda=$_GET["buscar"];
if (is_numeric($busqueda)){
$consulta="SELECT * FROM hoja1 WHERE codigo LIKE '%$busqueda%'";
$resultado=mysqli_query($conexion, $consulta);
}else{
$consulta="SELECT * FROM hoja1 WHERE materia LIKE '%$busqueda%'";
$resultado=mysqli_query($conexion, $consulta);
}
while($fila=mysqli_fetch_array($resultado, MYSQL_ASSOC)){
echo "<table border='1px' width='51%' align='left'><tr>";
echo "<td width='4%'>" . $fila['numero'] . "</td>";
echo "<td width='8%'>" . $fila['codigo'] . "</td>";
echo "<td width='30%'>" . $fila['materia'] . "</td>";
echo "<td width='8%'>" . $fila['seccion'] . "</td>";
echo "</tr></table>";
}
?>