so say we had 21 days and 12 of those days had profit i would like to have it dynamically update on our site to 57.1%
i have created a table just for this function with each day getting a separate entry
table layout
id | date | profit
x | 2011-10-4 | 54.76
i have the code below to return our first variable of 12, but after that i'm not getting anywhere after a few days
PS I would also love to know how to rid myself of this table (as i have to enter a record once daily) and be able to sql our entire database using GROUP BY 'date'
to find the number of positive days then just divide by the total number of GROUP BY 'date' results but i have no idea how to do that in php code
any help is much appreciated
Code: Select all
<?php
$query= "SELECT COUNT(date) FROM daybyday WHERE units >'0'";
$sql = mysql_query($query);
$countArray = mysql_fetch_array($sql);
$rows = $countArray[0];
//
echo $rows;
?>