I've got this piece of code:
$i=0;
$start_date = date("Y/m/d");
$end_date = date('Y/m/d', strtotime($start_date . " -7 days"));
while($days7=mysql_fetch_assoc($q)):
$next_date = strtotime($i--." days", strtotime($start_date));
$date = date("Y/m/d",$next_date);
#Let's get the latest click combined from the latest 7 days
$combined7=mysql_query("SELECT sum(value) FROM `xeon_stats_clicks` WHERE user='".$userdata['username']."' AND typ='4' AND data='$date' ORDER BY data DESC LIMIT 8") or die(mysql_error());
print mysql_num_rows($combined7);
endwhile;
I need to see how many rows that $combined7
is getting.
Currently, I am using print mysql_num_rows($combined7);
but that just prints out: 1 1 1 1 1 (The number '1' for each row)
How can I count the total number?
(P.S. $i have to be set to 0)
$i = 0; while($days7=mysql_fetch_assoc($q)): $i++;
? – user1326876 Sep 26 '13 at 12:21mysql_\*
as it has been deprecated. Usemysqli_\*
or PDO instead. ALSO, check out Bobby Tables – UnholyRanger Sep 26 '13 at 12:23SUM
back? So wouldn't you want to add aCOUNT
to the statement, then check the second column returned for the count? – UnholyRanger Sep 26 '13 at 12:27mysql_num_rows($combined7)
as it will be always 1 (your query will never return more than 1 row) – bansi Sep 26 '13 at 12:29