Hi everyone,
I have a bit of a problem here (I know I’m being stupid, but cannot for the life of me figure out how to do this)
I have a stats table for page visits (for a community website I am making for fun) and a graph to display the data, but at the moment am doing a query for each day of the current month for that particular user, then printing a comma (for the graph to work properly)
Instead of having 31 different queries running on the page what is the best way to loop through the table and printing the data in thiformat:
0,5,6,3,0,4,3,6, etc (obviously 30 times and days with no visits printing 0 and always a comma in between)
I apologize for my awful exaplanation but would greatly appreciate it if someone could give me a bit of advice (Im a real amateur at SQL and am struggling to understand what Im doing!)
Here is a snippet of the code I am using currently:
<?php
$curmon = date('m');
$pviews01 = mysql_query("SELECT * FROM `visitors_table` WHERE visitor_page = '".$_SESSION['username']."' AND visitor_day = '01' AND visitor_month = '".$curmon."' ");
$pv01 = mysql_num_rows($pviews01);
echo $pv01;
echo ',';
$pviews02 = mysql_query("SELECT * FROM `visitors_table` WHERE visitor_page = '".$_SESSION['username']."' AND visitor_day = '02' AND visitor_month = '".$curmon."' ");
$pv02 = mysql_num_rows($pviews02);
echo $pv02;
echo ',';
$pviews03 = mysql_query("SELECT * FROM `visitors_table` WHERE visitor_page = '".$_SESSION['username']."' AND visitor_day = '03' AND visitor_month = '".$curmon."' ");
$pv03 = mysql_num_rows($pviews03);
echo $pv03;
echo ',';
// THIS REPEATS 30 TIMES
?>