Good, I have this PHP code, with a database with the table "images" and with the fields: "id", "category" and "url". When I try to select all the images in a category, it only returns the first image of that category with the following notification:
Notice: Undefined offset: 1 in C: \ xampp \ htdocs \ projects \ 11 \ index.php on line 31
My PHP code is as follows:
$imagen_buscar = "Habitaciones";
require_once("conexion-bd.php");
try{
$sql_buscar = $mysqli->stmt_init();
$sql_buscar->prepare("SELECT url FROM imagenes WHERE categoria=?");
$sql_buscar->bind_param("s", $imagen_buscar);
$sql_buscar->execute();
$resultado = $sql_buscar->get_result();
//$fila = $resultado->fetch_row();
$fila = mysqli_fetch_array($resultado);
print_r($fila);
for($i=0; $i<5; $i++){
print_r("<img src='/proyectos/11/galeria/".$fila[$i]."' alt='Imagen buscada' width='50%' />");
}
unset($mysqli);
}catch (Exception $mysqli_ex3){
die("Se produjo el siguiente error: " . "<br/>" . $mysqli_ex3->getMessage() . "<br/>" . $mysqli_ex3->getCode() . "<br/>");
}
?>