#native_company# #native_desc#
#native_cta#

Mini Shopping Basket with only PHP4 Sessions Page 5

By Evert Smith
on August 17, 2000

Putting the Snippets Together
Lets put the code together and store it as minibasket.inc

<?php

// remember the code from Snipplet 1, deciding whether to add or not?

// Let's repeat it here

if ($basket!=""){

     
//In here items will be added to the basket. let's check if there is already

     //a basket registered.

     
if (session_is_registered("ses_basket_items")){

            
// There is a registered basket

            // Place Snipplet 4 here. It adds the item to the registered basket, checks

            // for duplicate entries, updates them or adds the item at the end of the

            // arrays.

     
} else {

            
// There is no basket registered

            // Place Snipplet 3 here. It creates a new basket and registers it with

            // the session.

     
}

}

// All there is left is Snipplet 2. It displays the basket if there are items in it.

// Add it here.

?>



Et voila. “c’est tout”, as the French would say. If all is done right, you can store this
file as minibasket.inc and include it into your PHP Page where you’re showing the articles.
— Evert

1
|
2
|
3
|
4
|
5