Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2009

    Unanswered: Help with session arrays

    Hi I am trying to use a session array to create a very simple shopping cart using php with odbc, I think my code is fine so far but I have limited experience and so any help would be great.

    my code so far is as follows

    $Conn = odbc_connect ('06', 'root', '');
    $cprid = $_POST['sel_item'];
    $cproduct = $_POST['sel_item_product'];
    $cprice = $_POST['sel_item_price'];
    $ctop = $_POST['sel_item_top'];
    $cqty = $_POST['sel_item_qty'];

    $_SESSION['cart'][] = array("productId" => $cprid,
    "product" => $cproduct,
    "price" => $cprice,
    "ptopping" => $ctop,
    "qty" => $cqty);



    however all this returns is the value array

    Am I correct in assuming each time the values are posted to this page they will be adding into the array or am I missing something out. also how would I go about listing the items in the array? I am guessing that I am going be using a whie statement?

    any help anyone can give me would be great.

  2. #2
    Join Date
    Jul 2009
    ok have made some progress and added

    foreach($_SESSION['cart'] as $cart)
    echo '<tr>';
    foreach($cart as $item)
    echo "<td>$item</td>";
    echo '</tr>';

    so now at list I know my array is working ad I an display a list of sort
    but till cant see how to pull each key out to use as I need

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts