7
I have a table in Mysql, which stores visits on my site, having as fields: id | ip | date, being the date of the kind DATETIME
.
What I need is to separate these visits by peak hours.
Example:
Das 10:00 às 12:00 | 500 visitas
Das 14:00 às 16:00 | 800 visitas
What I have today is a list of times and next to the number of visits, regardless of the amount.
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 you’ve had more visitors, how to do this?
What I got 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>
The code you posted doesn’t match what you put in "What I have today is ...".
– user4552