Hello i have this code to count visitors number from distinct ip adrress for all days stored in the table.
$con = mysql_connect("localhost", "root", "root") or die(mysql_error());
mysql_select_db("visitorsCount");
$page = $_GET['page']; //Page users visited with their ip
$queryTest = 'SELECT date, count(*),count(distinct ip) FROM `visitors` where section=\''.$page.'\' group by date order by date';
$result= mysql_query($queryTest);
$data = array();
while($ris=mysql_fetch_row($result))
{
$data[$ris[0]]=$ris[1]; // Render Visitor Count
}
print_r($data);
So, Print_r provides me this: Array ( [2015-02-03] => 1 [2015-05-03] => 14 )
.
But i want to restrict the query only for last 30 days in $queryTest
variable. How i can restrict the query only to show last 30 days records? Please have a look at the sql fiddle for the table structure. table struture