You are here: Re: creating a cumulative total column, but not in sequence « PHP Programming Language « IT news, forums, messages
Re: creating a cumulative total column, but not in sequence

Posted by mantrid on 12/29/07 23:50

"Ivαn Sαnchez Ortega" <ivansanchez-alg@rroba-escomposlinux.-.punto.-.org>
wrote in message news:fl6jjl$b55$1@hercules.cohp1...
> mantrid wrote:
>
> > Ok Ive been tinkering with your solution and my ignorance of arrays has
> > stumped me again.
>
> Do a <?php print_r($data); ?> after and before you re-sort the array by
> date. You should be able to look where the data goes wrong.
>
> Hint: if you're seeing the results through a web browser (as HTML), pop
> a "<pre>" before, and a "</pre>" after each print_r().
>
> --
> ----------------------------------
> Ivαn Sαnchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-
>
> For a light heart lives long.
> -- Shakespeare, "Love's Labour's Lost"
>

I did that and it displayed the following.


Array
(
[1] => Array
(
[0] => 0
[aimlisted] => 0
[1] => 1
[heldorder] => 1
[2] => D1 Oils Plc
[name] => D1 Oils Plc
[3] => DOO
[code] => DOO
[4] => 1594
[amount] => 1594
[5] => 1594
[sellamount] => 1594
[6] => 0
[boughtsold] => 0
[7] => 3637
[selllinkid] => 3637
[8] => 2007-10-18 15:00:00
[datetime] => 2007-10-18 15:00:00
[9] => 1.7437
[price] => 1.7437
[10] => 1.7334
[sellprice] => 1.7334
[11] => 2007-10-19 16:20:00
[selldatetime] => 2007-10-19 16:20:00
[12] => 20.397289
[charges] => 20.397289
[13] => 2799.855089
[total] => 2799.855089
[14] =>
[bb] =>
[15] => 2756.5396
[selltotal] => 2756.5396
[16] => -43.3154890000001
[profnloss] => -43.3154890000001
[17] => 0
[yrsheld] => 0
)

[150] => Array
(
[0] => 0
[aimlisted] => 0
[1] => 150
[heldorder] => 150
[2] => Alkane Energy
[name] => Alkane Energy
[3] => ALK
[code] => ALK
[4] => 13793
[amount] => 13793
[5] => 13793
[sellamount] => 13793
[6] => 0
[boughtsold] => 0
[7] => 3639
[selllinkid] => 3639
[8] => 2007-06-05 16:23:00
[datetime] => 2007-06-05 16:23:00
[9] => 0.2159
[price] => 0.2159
[10] => 0.1973
[sellprice] => 0.1973
[11] => 2007-11-02 08:17:00
[selldatetime] => 2007-11-02 08:17:00
[12] => 21.3895435
[charges] => 21.3895435
[13] => 2999.2982435
[total] => 2999.2982435
[14] =>
[bb] =>
[15] => 2714.8589
[selltotal] => 2714.8589
[16] => -284.4393435
[profnloss] => -284.4393435
[17] => 0
[yrsheld] => 0
)

[338] => Array
(
[0] => 0
[aimlisted] => 0
[1] => 338
[heldorder] => 338
[2] => TRADING EMISSIO ORD GBP0.01
[name] => TRADING EMISSIO ORD GBP0.01
[3] => TRE
[code] => TRE
[4] => 750
[amount] => 750
[5] => 2197
[sellamount] => 2197
[6] => 0
[boughtsold] => 0
[7] => 3625
[selllinkid] => 3625
[8] => 2006-05-30 15:55:00
[datetime] => 2006-05-30 15:55:00
[9] => 1.2625
[price] => 1.2625
[10] => 1.56
[sellprice] => 1.56
[11] => 2007-05-03 16:14:00
[selldatetime] => 2007-05-03 16:14:00
[12] => 8.23333333333
[charges] => 8.23333333333
[13] => 955.10833333333
[total] => 955.10833333333
[14] =>
[bb] =>
[15] => 1163.5
[selltotal] => 1163.5
[16] => 208.39166666667
[profnloss] => 208.39166666667
[17] => 0
[yrsheld] => 0
)

[370] => Array
(
[0] => 0
[aimlisted] => 0
[1] => 370
[heldorder] => 370
[2] => TRADING EMISSIO ORD GBP0.01
[name] => TRADING EMISSIO ORD GBP0.01
[3] => TRE
[code] => TRE
[4] => 498
[amount] => 498
[5] => 2197
[sellamount] => 2197
[6] => 0
[boughtsold] => 0
[7] => 3625
[selllinkid] => 3625
[8] => 2006-04-28 09:13:00
[datetime] => 2006-04-28 09:13:00
[9] => 1.5075
[price] => 1.5075
[10] => 1.56
[sellprice] => 1.56
[11] => 2007-05-03 16:14:00
[selldatetime] => 2007-05-03 16:14:00
[12] => 10.75
[charges] => 10.75
[13] => 761.485
[total] => 761.485
[14] =>
[bb] =>
[15] => 770.38
[selltotal] => 770.38
[16] => 8.89499999999998
[profnloss] => 8.89499999999998
[17] => 1
[yrsheld] => 1
)

[371] => Array
(
[0] => 0
[aimlisted] => 0
[1] => 371
[heldorder] => 371
[2] => TRADING EMISSIO ORD GBP0.01
[name] => TRADING EMISSIO ORD GBP0.01
[3] => TRE
[code] => TRE
[4] => 949
[amount] => 949
[5] => 2197
[sellamount] => 2197
[6] => 0
[boughtsold] => 0
[7] => 3625
[selllinkid] => 3625
[8] => 2006-04-27 09:46:00
[datetime] => 2006-04-27 09:46:00
[9] => 1.58
[price] => 1.58
[10] => 1.56
[sellprice] => 1.56
[11] => 2007-05-03 16:14:00
[selldatetime] => 2007-05-03 16:14:00
[12] => 14.5
[charges] => 14.5
[13] => 1513.92
[total] => 1513.92
[14] =>
[bb] =>
[15] => 1473.94
[selltotal] => 1473.94
[16] => -39.98
[profnloss] => -39.98
[17] => 1
[yrsheld] => 1
)

[377] => Array
(
[0] => 0
[aimlisted] => 0
[1] => 377
[heldorder] => 377
[2] => RENEWABLE ENERGY HLDGS ORD GBP0.01
[name] => RENEWABLE ENERGY HLDGS ORD GBP0.01
[3] => REH
[code] => REH
[4] => 4167
[amount] => 4167
[5] => 4167
[sellamount] => 4167
[6] => 0
[boughtsold] => 0
[7] => 3630
[selllinkid] => 3630
[8] => 2006-05-30 16:20:00
[datetime] => 2006-05-30 16:20:00
[9] => 0.465
[price] => 0.465
[10] => 0.49
[sellprice] => 0.49
[11] => 2007-06-11 16:21:00
[selldatetime] => 2007-06-11 16:21:00
[12] => 16.69
[charges] => 16.69
[13] => 1954.345
[total] => 1954.345
[14] =>
[bb] =>
[15] => 2035.33
[selltotal] => 2035.33
[16] => 80.9849999999997
[profnloss] => 80.9849999999997
[17] => 1
[yrsheld] => 1
)

[631] => Array
(
[0] => 0
[aimlisted] => 0
[1] => 631
[heldorder] => 631
[2] => RENEWABLE ENERGY HLDGS ORD GBP0.01
[name] => RENEWABLE ENERGY HLDGS ORD GBP0.01
[3] => REH
[code] => REH
[4] => 5410
[amount] => 5410
[5] => 5410
[sellamount] => 5410
[6] => 0
[boughtsold] => 0
[7] => 3635
[selllinkid] => 3635
[8] => 2006-01-25 16:07:00
[datetime] => 2006-01-25 16:07:00
[9] => 0.6025
[price] => 0.6025
[10] => 0.53
[sellprice] => 0.53
[11] => 2007-10-18 15:00:00
[selldatetime] => 2007-10-18 15:00:00
[12] => 23.3
[charges] => 23.3
[13] => 3282.825
[total] => 3282.825
[14] =>
[bb] =>
[15] => 2860.8
[selltotal] => 2860.8
[16] => -422.025
[profnloss] => -422.025
[17] => 1
[yrsheld] => 1
)

[687] => Array
(
[0] => 0
[aimlisted] => 0
[1] => 687
[heldorder] => 687
[2] => Tepnel Life
[name] => Tepnel Life
[3] => TED
[code] => TED
[4] => 41818
[amount] => 41818
[5] => 78857
[sellamount] => 78857
[6] => 0
[boughtsold] => 0
[7] => 3627
[selllinkid] => 3627
[8] => 2005-07-14 00:05:04
[datetime] => 2005-07-14 00:05:04
[9] => 0.11
[price] => 0.11
[10] => 0.095
[sellprice] => 0.095
[11] => 2007-06-01 12:42:00
[selldatetime] => 2007-06-01 12:42:00
[12] => 30
[charges] => 30
[13] => 4629.98
[total] => 4629.98
[14] =>
[bb] =>
[15] => 3966.21
[selltotal] => 3966.21
[16] => -663.77
[profnloss] => -663.77
[17] => 1
[yrsheld] => 1
)

[688] => Array
(
[0] => 0
[aimlisted] => 0
[1] => 688
[heldorder] => 688
[2] => Tepnel Life
[name] => Tepnel Life
[3] => TED
[code] => TED
[4] => 37039
[amount] => 37039
[5] => 78857
[sellamount] => 78857
[6] => 0
[boughtsold] => 0
[7] => 3627
[selllinkid] => 3627
[8] => 2005-07-13 00:05:02
[datetime] => 2005-07-13 00:05:02
[9] => 0.09
[price] => 0.09
[10] => 0.095
[sellprice] => 0.095
[11] => 2007-06-01 12:42:00
[selldatetime] => 2007-06-01 12:42:00
[12] => 20.1695931877
[charges] => 20.1695931877
[13] => 3353.6795931877
[total] => 3353.6795931877
[14] =>
[bb] =>
[15] => 3512.205
[selltotal] => 3512.205
[16] => 158.5254068123
[profnloss] => 158.5254068123
[17] => 1
[yrsheld] => 1
)

[750] => Array
(
[0] => 0
[aimlisted] => 0
[1] => 750
[heldorder] => 750
[2] => Tepnel Life
[name] => Tepnel Life
[3] => TED
[code] => TED
[4] => 41818
[amount] => 41818
[5] => 41818
[sellamount] => 41818
[6] => 0
[boughtsold] => 0
[7] => 3633
[selllinkid] => 3633
[8] => 2005-07-13 00:05:02
[datetime] => 2005-07-13 00:05:02
[9] => 0.09
[price] => 0.09
[10] => 0.1038
[sellprice] => 0.1038
[11] => 2007-08-02 12:07:00
[selldatetime] => 2007-08-02 12:07:00
[12] => 22.3204068123
[charges] => 22.3204068123
[13] => 3785.9404068123
[total] => 3785.9404068123
[14] =>
[bb] =>
[15] => 4334.2084
[selltotal] => 4334.2084
[16] => 548.267993187701
[profnloss] => 548.267993187701
[17] => 2
[yrsheld] => 2
)

[key] => Array
(
[accum] => 1005.06506667
)

)
Array
(
[1] => Array
(
[0] => 0
[aimlisted] => 0
[1] => 1
[heldorder] => 1
[2] => D1 Oils Plc
[name] => D1 Oils Plc
[3] => DOO
[code] => DOO
[4] => 1594
[amount] => 1594
[5] => 1594
[sellamount] => 1594
[6] => 0
[boughtsold] => 0
[7] => 3637
[selllinkid] => 3637
[8] => 2007-10-18 15:00:00
[datetime] => 2007-10-18 15:00:00
[9] => 1.7437
[price] => 1.7437
[10] => 1.7334
[sellprice] => 1.7334
[11] => 2007-10-19 16:20:00
[selldatetime] => 2007-10-19 16:20:00
[12] => 20.397289
[charges] => 20.397289
[13] => 2799.855089
[total] => 2799.855089
[14] =>
[bb] =>
[15] => 2756.5396
[selltotal] => 2756.5396
[16] => -43.3154890000001
[profnloss] => -43.3154890000001
[17] => 0
[yrsheld] => 0
)

[150] => Array
(
[0] => 0
[aimlisted] => 0
[1] => 150
[heldorder] => 150
[2] => Alkane Energy
[name] => Alkane Energy
[3] => ALK
[code] => ALK
[4] => 13793
[amount] => 13793
[5] => 13793
[sellamount] => 13793
[6] => 0
[boughtsold] => 0
[7] => 3639
[selllinkid] => 3639
[8] => 2007-06-05 16:23:00
[datetime] => 2007-06-05 16:23:00
[9] => 0.2159
[price] => 0.2159
[10] => 0.1973
[sellprice] => 0.1973
[11] => 2007-11-02 08:17:00
[selldatetime] => 2007-11-02 08:17:00
[12] => 21.3895435
[charges] => 21.3895435
[13] => 2999.2982435
[total] => 2999.2982435
[14] =>
[bb] =>
[15] => 2714.8589
[selltotal] => 2714.8589
[16] => -284.4393435
[profnloss] => -284.4393435
[17] => 0
[yrsheld] => 0
)

[338] => Array
(
[0] => 0
[aimlisted] => 0
[1] => 338
[heldorder] => 338
[2] => TRADING EMISSIO ORD GBP0.01
[name] => TRADING EMISSIO ORD GBP0.01
[3] => TRE
[code] => TRE
[4] => 750
[amount] => 750
[5] => 2197
[sellamount] => 2197
[6] => 0
[boughtsold] => 0
[7] => 3625
[selllinkid] => 3625
[8] => 2006-05-30 15:55:00
[datetime] => 2006-05-30 15:55:00
[9] => 1.2625
[price] => 1.2625
[10] => 1.56
[sellprice] => 1.56
[11] => 2007-05-03 16:14:00
[selldatetime] => 2007-05-03 16:14:00
[12] => 8.23333333333
[charges] => 8.23333333333
[13] => 955.10833333333
[total] => 955.10833333333
[14] =>
[bb] =>
[15] => 1163.5
[selltotal] => 1163.5
[16] => 208.39166666667
[profnloss] => 208.39166666667
[17] => 0
[yrsheld] => 0
)

[370] => Array
(
[0] => 0
[aimlisted] => 0
[1] => 370
[heldorder] => 370
[2] => TRADING EMISSIO ORD GBP0.01
[name] => TRADING EMISSIO ORD GBP0.01
[3] => TRE
[code] => TRE
[4] => 498
[amount] => 498
[5] => 2197
[sellamount] => 2197
[6] => 0
[boughtsold] => 0
[7] => 3625
[selllinkid] => 3625
[8] => 2006-04-28 09:13:00
[datetime] => 2006-04-28 09:13:00
[9] => 1.5075
[price] => 1.5075
[10] => 1.56
[sellprice] => 1.56
[11] => 2007-05-03 16:14:00
[selldatetime] => 2007-05-03 16:14:00
[12] => 10.75
[charges] => 10.75
[13] => 761.485
[total] => 761.485
[14] =>
[bb] =>
[15] => 770.38
[selltotal] => 770.38
[16] => 8.89499999999998
[profnloss] => 8.89499999999998
[17] => 1
[yrsheld] => 1
)

[371] => Array
(
[0] => 0
[aimlisted] => 0
[1] => 371
[heldorder] => 371
[2] => TRADING EMISSIO ORD GBP0.01
[name] => TRADING EMISSIO ORD GBP0.01
[3] => TRE
[code] => TRE
[4] => 949
[amount] => 949
[5] => 2197
[sellamount] => 2197
[6] => 0
[boughtsold] => 0
[7] => 3625
[selllinkid] => 3625
[8] => 2006-04-27 09:46:00
[datetime] => 2006-04-27 09:46:00
[9] => 1.58
[price] => 1.58
[10] => 1.56
[sellprice] => 1.56
[11] => 2007-05-03 16:14:00
[selldatetime] => 2007-05-03 16:14:00
[12] => 14.5
[charges] => 14.5
[13] => 1513.92
[total] => 1513.92
[14] =>
[bb] =>
[15] => 1473.94
[selltotal] => 1473.94
[16] => -39.98
[profnloss] => -39.98
[17] => 1
[yrsheld] => 1
)

[377] => Array
(
[0] => 0
[aimlisted] => 0
[1] => 377
[heldorder] => 377
[2] => RENEWABLE ENERGY HLDGS ORD GBP0.01
[name] => RENEWABLE ENERGY HLDGS ORD GBP0.01
[3] => REH
[code] => REH
[4] => 4167
[amount] => 4167
[5] => 4167
[sellamount] => 4167
[6] => 0
[boughtsold] => 0
[7] => 3630
[selllinkid] => 3630
[8] => 2006-05-30 16:20:00
[datetime] => 2006-05-30 16:20:00
[9] => 0.465
[price] => 0.465
[10] => 0.49
[sellprice] => 0.49
[11] => 2007-06-11 16:21:00
[selldatetime] => 2007-06-11 16:21:00
[12] => 16.69
[charges] => 16.69
[13] => 1954.345
[total] => 1954.345
[14] =>
[bb] =>
[15] => 2035.33
[selltotal] => 2035.33
[16] => 80.9849999999997
[profnloss] => 80.9849999999997
[17] => 1
[yrsheld] => 1
)

[631] => Array
(
[0] => 0
[aimlisted] => 0
[1] => 631
[heldorder] => 631
[2] => RENEWABLE ENERGY HLDGS ORD GBP0.01
[name] => RENEWABLE ENERGY HLDGS ORD GBP0.01
[3] => REH
[code] => REH
[4] => 5410
[amount] => 5410
[5] => 5410
[sellamount] => 5410
[6] => 0
[boughtsold] => 0
[7] => 3635
[selllinkid] => 3635
[8] => 2006-01-25 16:07:00
[datetime] => 2006-01-25 16:07:00
[9] => 0.6025
[price] => 0.6025
[10] => 0.53
[sellprice] => 0.53
[11] => 2007-10-18 15:00:00
[selldatetime] => 2007-10-18 15:00:00
[12] => 23.3
[charges] => 23.3
[13] => 3282.825
[total] => 3282.825
[14] =>
[bb] =>
[15] => 2860.8
[selltotal] => 2860.8
[16] => -422.025
[profnloss] => -422.025
[17] => 1
[yrsheld] => 1
)

[687] => Array
(
[0] => 0
[aimlisted] => 0
[1] => 687
[heldorder] => 687
[2] => Tepnel Life
[name] => Tepnel Life
[3] => TED
[code] => TED
[4] => 41818
[amount] => 41818
[5] => 78857
[sellamount] => 78857
[6] => 0
[boughtsold] => 0
[7] => 3627
[selllinkid] => 3627
[8] => 2005-07-14 00:05:04
[datetime] => 2005-07-14 00:05:04
[9] => 0.11
[price] => 0.11
[10] => 0.095
[sellprice] => 0.095
[11] => 2007-06-01 12:42:00
[selldatetime] => 2007-06-01 12:42:00
[12] => 30
[charges] => 30
[13] => 4629.98
[total] => 4629.98
[14] =>
[bb] =>
[15] => 3966.21
[selltotal] => 3966.21
[16] => -663.77
[profnloss] => -663.77
[17] => 1
[yrsheld] => 1
)

[688] => Array
(
[0] => 0
[aimlisted] => 0
[1] => 688
[heldorder] => 688
[2] => Tepnel Life
[name] => Tepnel Life
[3] => TED
[code] => TED
[4] => 37039
[amount] => 37039
[5] => 78857
[sellamount] => 78857
[6] => 0
[boughtsold] => 0
[7] => 3627
[selllinkid] => 3627
[8] => 2005-07-13 00:05:02
[datetime] => 2005-07-13 00:05:02
[9] => 0.09
[price] => 0.09
[10] => 0.095
[sellprice] => 0.095
[11] => 2007-06-01 12:42:00
[selldatetime] => 2007-06-01 12:42:00
[12] => 20.1695931877
[charges] => 20.1695931877
[13] => 3353.6795931877
[total] => 3353.6795931877
[14] =>
[bb] =>
[15] => 3512.205
[selltotal] => 3512.205
[16] => 158.5254068123
[profnloss] => 158.5254068123
[17] => 1
[yrsheld] => 1
)

[750] => Array
(
[0] => 0
[aimlisted] => 0
[1] => 750
[heldorder] => 750
[2] => Tepnel Life
[name] => Tepnel Life
[3] => TED
[code] => TED
[4] => 41818
[amount] => 41818
[5] => 41818
[sellamount] => 41818
[6] => 0
[boughtsold] => 0
[7] => 3633
[selllinkid] => 3633
[8] => 2005-07-13 00:05:02
[datetime] => 2005-07-13 00:05:02
[9] => 0.09
[price] => 0.09
[10] => 0.1038
[sellprice] => 0.1038
[11] => 2007-08-02 12:07:00
[selldatetime] => 2007-08-02 12:07:00
[12] => 22.3204068123
[charges] => 22.3204068123
[13] => 3785.9404068123
[total] => 3785.9404068123
[14] =>
[bb] =>
[15] => 4334.2084
[selltotal] => 4334.2084
[16] => 548.267993187701
[profnloss] => 548.267993187701
[17] => 2
[yrsheld] => 2
)

[key] => Array
(
[accum] => 1005.06506667
)

)
Which suggests the syntax for creating data2 is wrong somehow?Ian

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация