I have a table in MySQL, which stores the visits on my site, taking as fields: id | ip | date , with date of type DATETIME
.
What I need is to separate these visits by peak times.
Example:
Das 10:00 às 12:00 | 500 visitas
Das 14:00 às 16:00 | 800 visitas
What I have today is the list of times and the number of visits regardless of quantity.
Das 06:00 às 08:00 | 220
Das 08:00 às 10:00 | 410
Das 10:00 às 12:00 | 105
I need to sort by the time I had more visits, how to do this?
What I have now is this:
<?php
$sel_visitas = mysql_query("SELECT * FROM acessos_site");
if(mysql_num_rows($sel_visitas) >= 1){
$sel_00_06 = mysql_query("SELECT * FROM acessos_site WHERE TIME(data) BETWEEN '00:00:00' AND '06:00:00'");
$visitas_00_06 = mysql_num_rows($sel_00_06);
?>
<table border="0" style="width:940px;">
<tr class="tit">
<td>Horário</td>
<td>Visitas</td>
<tr>
<tr>
<td>Das 00:00 às 06:00</td>
<td><?php echo $visitas_00_06;?></td>
</tr>
</table>