problems with sessions

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • problems with sessions

    I have this array, how can I put same toote_id values together so that toote_id[0] and toote_id[3] are the same (when printing out).
    Then for them the price (toote_hind" should be also the same -> toote_hind[0] + toote_hind[3]
    And now the amount "toote_hulk" should be toote_hulk[0] + toote_hulk[3]

    how to do that?

    Array (
    [ostmine] => Array
    (
    [toote_id] => Array ( )
    [toote_hind] => Array ( )
    [toote_hulk] => Array ( )
    [toote_kood] => Array ( )
    [ostetud] => 1
    )
    [toote_id] => Array
    (
    [0] => 19
    [1] => 16
    [2] => 1
    [3] => 19
    [4] => 3
    )
    [toote_hind] => Array
    (
    [0] => 209
    [1] => 99
    [2] => 500
    [3] => 209
    [4] => 69.95
    )
    [toote_hulk] => Array
    (
    [0] => 6
    [1] => 9
    [2] => 1
    [3] => 2
    [4] => 8
    )
    [toote_kood] => Array
    (
    [0] => u1a257p3r299g2o991Q1r4P2o7E17939
    [1] => r2W582n1u1y4R5Y461w4q371017279w3
    [2] => 92r6q6o219z218h1w914n5590143n4v4
    [3] => R1o1r189z2h1p532r932t7w68699W6F2
    [4] => a2q1v9g1b912z1u68277c5s4P2q9q7h7
    )
    )

  • #2
    I made it other way:

    [tID_tHIND_tHULK_tKOOD] => Array
    (
    [0] => 19|209|1|e9P1m963u5S3d58542e40415o9o3t126
    [1] => 17|100|4|P609c4l1S4n5Q4t169h2b3w472e4k324
    [2] => 19|209|7|q3g4a5h2E1g7i7n5r1W997n9w6g8h1z3
    [3] => 3|69.95|14|J6t1r5E255i622T5q19244h651z546W1
    )

    tID is the product ID
    tHIND is the price of the product
    tHULK is the amount of the product
    tKOOD is automatically generated code

    as we see, we have there two products with ID 19
    how I print out these products so that I see only one product with the ID 19 but the tHULK and tHIND will go together (209+209) and (1+7)?

    how? please help

    feel free to answer in German

    thanks

    Kommentar


    • #3
      if yor are capable of chagning the structure why don't you look whether you already have the product with id #19 already saved in your array and simply implement kind of a counter that you increment?

      Code:
      Array products
      #id amount
       19 2
       25 1
        7 5
      PHP-Code:
      if (!isset($products[$key]))
        
      $products[$key]=0;
      $products[$key]++; 
      Ich denke, also bin ich. - Einige sind trotzdem...

      Kommentar

      Lädt...
      X