$tab_jour=array();
for($i = 1; $i <= 7; $i++){
$req = "select count(id) as nb_news from news where `timestamp` between 20$annee$month$day_precedent and 20$annee$month$day";
echo $req."<br>";
$result = mysql_query($req) or die( $req . '<br />' . mysql_error() );
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$day = str_pad($day_precedent, 2, "0", STR_PAD_LEFT); //le jour actuel devient le jour precedent
$day_precedent = $day_precedent-1; //idem ci dessus
$tab_jour[$i].= $row["nb_news"];
}
echo "<br>";
return($tab_jour[$i]);
}
et comme vous l'aurez compris je cherche à retourner $tab_jour pour afficher les résultat dans un tableau. Dans mon fichier qui reçoit la fonction:
requete_current_day();
<tr bgcolor="#e6e8ec" align="center">
<td width="10%" ><? echo "20".$annee; ?></td>
<td width="10%"><a hre="#" class="info"><? echo $tab_jour[7] ; ?><span>heure de pointe<br>pages vues</span></a></td>
<td width="10%"><a hre="#" class="info"><? echo $tab_jour[6]; ?><span>test</span></td>
<td width="10%"><a hre="#" class="info"><? echo $tab_jour[5]; ?><span>test</span></td>
<td width="10%"><a hre="#" class="info"><? echo $tab_jour[4]; ?><span>test</span></td>
<td width="10%"><a hre="#" class="info"><? echo $tab_jour[3]; ?><span>test</span></td>
<td width="10%"><a hre="#" class="info"><? echo $tab_jour[2]; ?><span>test</span></td>
<td width="10%"><a hre="#" class="info"><? echo $tab_jour[1]; ?><span>test</span></td>
</tr>
Merci