In phpmyadmin I Get the result expected, it means, daily number of vacations in a range of days, however I can't make it work on PHP and I get only the firs row of the whole array.
$mysqli = mysqli_connect("localhost", "andes", "andes123","andes");
$query= "select calendar_table.dt, count(BP) as 'Number'
from calendar_table
left join tbl021_vacaciones on calendar_table.dt between
tbl021_vacaciones.fecha_inicio and tbl021_vacaciones.fecha_fin
where (calendar_table.dt between '2016-01-29' and '2016-03-31')
group by calendar_table.dt";
$request=mysqli_query($mysqli,$query);
$row=mysqli_fetch_array($request);
$Resultado= print_r ($row['dt'], $row['Number']);
I know that I am doing it wrong, but I cannot make it work to save the results into a single PHP
To fetch all results you need to loop :
while($row=mysqli_fetch_assoc($request)) {
//echo $row['dt'];
}
To obtain all the rows of a mysqli query:
$rows = mysqli_fetch_all( $request, MYSQLI_ASSOC );
or:
while( $row = mysqli_fetch_array( $request ) )
{
print_r( $row['dt'] );
}
MYSQLI_ASSOC
means to fetch only as associative arrays. Otherwise, you will obtain both numeric and associative index, like in your example (BTW, this is not an error in your original code).