Good morning, everyone. This question I have already seen in several issues but I do not understand very well what is the problem of why it does not enter the results in an array. I know that the query returns results.
I leave code:
function jsonEcho(){
include('conn.php');
$servername = "localhost";
$ttenQ="SELECT 'id', 'nombre_cock', 'categoria_fk', 'descripcion','Preparacion', 'img_path', 'puntuacion' FROM 'def_cockteles' ORDER BY 'puntuacion' DESC LIMIT 10";
$resultado = mysqli_query($conexion,$ttenQ);
$topTen = array();
$rowcount=mysqli_num_rows($resultado);
printf("Result set has %d rows.\n",$rowcount);
while ($row=mysqli_fetch_array($resultado)) {
$topTen[]=array('ruta'=> $row["img_path"],'descripcion'=>$row["descripcion"]);
}
return json_encode($topTen);
}
print_r(jsonEcho());
?>
Thanks in advance