Php problems!

Status
Not open for further replies.

mulesy

Solid State Member
Messages
10
Hi,

Im finding php really hard to use and was hoping some one would help me on a few problems.

Ive designed a website a dvd website for a project i had to do
the website it self is completed. i have a buy button after each item but i want it to work out how much the item is and add to it to a sort of cart i aint a clue how to start could anyone help me?

When that one item is ready to buy i want it to confirm as well so it takes it out of a database thats is gonna be a pain as well!

Can anyone help!!

with thanks
Jason
 
The most simple approach is to use an array to store items added to the a cart. You can attach the array to a users session.

Code:
$ary_strCartItems = Array(); // Init array
session_start(); // Start session and load data if session exists
if(!session_is_registered('cart')) session_register('cart');
if(isset($_SESSION['cart'])) $ary_strCartItems = $_SESSION['cart']; // Fill cart array if exists.

When someone clicks a link to add to the cart.
Code:
// Use code above plus...
$ary_strCartItems[] = 'Shirt'; // Append an item to the cart
$_SESSION['cart'] = $ary_strCartItems;
 
thanks for that mate, if i have any more problems would it be possible to help me stuggling so badly with this
 
Status
Not open for further replies.
Back
Top Bottom