nostic Posted November 3, 2011 Share Posted November 3, 2011 Hello EVERYONE! I've been tasked with creating a weighted sales forcast for our sales team and I have decided to use highcharts for the graphing. I am having some issues with the exact query I need to run and am hoping someone can help me out. Here is my current query: <?php $SecurityQuery = "SELECT (sum(amount * (probability / 100))) as weighted FROM opportunities INNER JOIN users on assigned_user_id = users.id WHERE department = 'Security' and opportunities.probability != '100' and opportunities.probability != '0' group by WEEK(opportunities.date_entered)"; $result = mysql_query($SecurityQuery); ?> and I am filling an array to graph with <?php while($row = mysql_fetch_assoc($result)) { echo $row['weighted']. ","; } ?> which is populating the array correctly with values suchs as [14000,22000,18000,19000], what I need though is to add each number in the array to all previous values. So I would like the array to actually populate like so [14000,36000,54000,73000]. Can anyone point me in the right direction to do this? I know I can actual just do it though specific sql querys where I select the data for just that week then add it to the other week and just keep going, however that seems like the long way about it and there has to be a way to do this though a while loop...or am I crazy? thanks! Quote Link to comment Share on other sites More sharing options...
fenway Posted November 6, 2011 Share Posted November 6, 2011 You can store the sum into a user variable that you keep incrementing -- just remember to set it in the same statement. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.