1. #1

    More PHP problems =[


    This is the second issue I am having with the PHP I am working on:

    For the shopping basket of the website I have an session array called list. Which has book details added in, Now the complicated bit is getting the array variables and put them back into a different table.


    User Adds products to shopping list
    Shopping list to checkout (List to order table)

    Now this is the addtolist.php which adds the user's choices to the "shopping list" array. What I need to do next is somehow figure out a way to get the bookarray variables into an order table. Now I know the SQL functions for it:

    $query = "INSERT INTO orderhistory VALUES ('".$ISBN."','".$bookname."','".$author."','".$price."')";
    session_start();if ( !isset($_SESSION['username']) ){ header("Location:index.php"); exit(); }$bookarray = array();$bookarray['ISBN'] = $_GET['ISBN'];$bookarray['bookname'] = $_GET['bookname'];$bookarray['author'] = $_GET['author'];$bookarray['price'] = $_GET['price'];$found = false;if (isset($_SESSION['list'])) { foreach ($_SESSION['list'] as $key => $another) { if ($_SESSION['list'][$key]['ISBN'] == $_GET['ISBN']) { $found = true; break; } } }if ($found == false) { $_SESSION['list'] [] = $bookarray; } header("Location: products.php");

    When I run:
    Print_r ($_SESSION['list']);"

    It prints of the contents of session list but I do not know how to gain access to them in order to insert them into a new table?

    The part I am confused or stuck at is I am making an addtobasket.php file and getting the $_SESSION variables from the array is mind-boggling. =/

    Any help? I promise this will be the last time!

    Thanks for any help! It is much appreciated! :)
    Last edited by silverj2k7; 04-16-2012 at 08:22 PM. Reason: Updated

    • Ad Bot



Similar Threads

  1. PHP Help
    By AceInfinity in forum Programming
    Replies: 10
    Last Post: 03-31-2013, 01:33 AM
  2. [PHP] header_check.php
    By Will Watts in forum Programming
    Replies: 8
    Last Post: 01-21-2013, 10:16 PM
  3. [SOLVED] PHP Registration grief! :(
    By silverj2k7 in forum Programming
    Replies: 7
    Last Post: 04-17-2012, 10:58 PM

Log in

Log in