mysql - PHP assign result from nested query into array -


I want help to assign the results of the nested query in the array This scenario is:

 < Code> $ closing date = mysql_query ("selected date from TblDate"); While ($ date = mysql_fetch_array ($ date_Collection)) // Loop {$ var_date = $ date ['date'] via all dates; Select $ Result = mysql_query ("Min_spd as Minimum (Speed), Max_spind as Max (Speed), Average (Speed) to AVG_SPD ... where date = $ var_date"); While ($ line = mysql_fetch_array ($ result)) {resonant "row [min_spad]"; Resonant "row [maxspace]"; Echo "line [average_spid]"; }}   

The output from this query is as follows:

  Min_Spd | Max_Spd | Avg_Spd | Date | 12.0 | 25.0 | 20.4 | 2012-10-01 | 11.0 | 28.0 | 21.4 | 2012-10-02 | 10.0 | 26.0 | 23.4 | 2012-10-05 | 08.0 | 22.0 | 21.4 | 2012-10-08 | I have to basically show the sum of Min_Spd, Sum of Max_spd, Sum of Avg_spd for all these dates. So, I thought that if I specify these values ​​in an array I can do this and later calculate this amount from the array, so it can be a good idea.  

Can anyone help me in this matter? Can I use an array to store the values ​​and later I can use these values ​​and calculate the amount of these values. If I can use an array, can someone show me the syntax of using the array in PHP. I appreciate any help about this.

Is there a temporary method rather than using an array, such as creating a temporary table to save these values ​​and later destroying the temporary table if a temporary table can be used Can you please show me how to do this I can use temptation for a single loop, but there is a nested loop and I do not know at all that all the values ​​inside the nested loop What to do to create a temporary table to store them.

  $ data = array (); While ($ line = mysql_fetch_assoc ($ result)) {$ data [=] $ line; }   

then you can

  foreach ($ data as $ line) {echo $ row ['min_spd']; Echo ... ...}    

Comments