I am trying to make a SELECT
using MySQLi
and PREPARE
in FOR
but not working. It is always returning a single zero.
Application code:
if( $teste = $mysqli->prepare("SELECT COUNT(*) AS TOTAL_CONTATOS, 'data' AS DATA_CONTATO FROM 'contatos' WHERE 'data' >=? AND 'data' <=?") )
{
$mes = date("m");
$ano = date("Y");
$data_start = "01-".$mes."-".$ano;
$tempo_start = strtotime($data_start);
$tempo_end = strtotime("+1 month", $tempo_start);
for( $i = $tempo_start; $i < $tempo_end; $i += 86400 )
{
$teste->bind_param( 'ss', date('Y-m-d', $i), date('Y-m-d', $tempo_end) );
$teste->execute();
$teste->bind_result( $totalcontato, $data_contato);
$teste->store_result();
}
while( $teste->fetch() )
{
echo $totalcontato ." | ". $data_contato;
echo "<br>";
}
}