I have two input that passes a range of dates to the program in php that I have to return some ids, the problem is that it does not return anything, all in white:
Desde Fecha <input name="desde_fecha_cumple" type="date" value="<?php echo date("Y-m-d"); ?>"/><br />
Hasta fecha <input name="hasta_fecha_cumple" type="date" value="<?php echo date("Y-m-d"); ?>"/><br />
These are the inputs, and the program in php:
function ids_cumplen_anos($fecha) {
$link = mysql_connect("localhost", "XX", "XXX");
mysql_select_db("XX_database", $link);
$sql = "select id from usuario where day(FechaNacimiento)>=day('" . $fecha . "') and month(FechaNacimiento)>=month('" . $fecha . "') AND day(FechaNacimiento)<=day('" . $fecha ."') and month(FechaNacimiento)<=month('" . $fecha ."')"; //funcion sacar cumple
$result = mysql_query($sql, $link);
$socios = array();
if ($result) {
//echo "hay resultados";
while ($row = mysql_fetch_assoc($result)) {
$socios[] = $row['id'];
}
}
if (!count($socios))
$socios = 0;
return $socios;
}
This has to generate an excel with the following code:
"datos" => obtener_socios(ids_cumplen_anos($datos['desde_fecha_cumple'], $datos['hasta_fecha_cumple'], $datos['opt']));
How can I make the range of dates so that both are passed to the program in php and this is printed in the excel?
I made an echo of $ sql and it only returns a date
In the first input I indicated 02/03/2017
and in the second input 04/04/2017
This is the query:
select id from user where day (Birthdate) > = day ('2017-03-02') and month (Birthdate) > = month ('2017-03-02') and day (Birthdate) < = day ('2017-03-02') and month (Birthdate) < = month ('2017-03-02')
The same first value of the first input in all, does not take the second value of the second input.
Edit2-- You already take both values from the dates but you do not paint the ids of the partners that have years between that range.