silverj2k7
Member
- Apr 15, 2012
- 6
Hiya
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.
Basically:
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:
Update
When I run:
"<?php
session_start();
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! :)
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.
Basically:
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:
Code:
[LEFT][COLOR=#000000][FONT=verdana]$query = "INSERT INTO orderhistory VALUES ('".$ISBN."','".$bookname."','".$author."','".$price."')";[/FONT][/COLOR][/LEFT]
Code:
[LEFT][COLOR=#000000]<?php[/COLOR][/LEFT]
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"); [LEFT][COLOR=#000000] exit[/COLOR][/LEFT]
Update
When I run:
"<?php
session_start();
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: