Hi all i have a shopping cart, which uses db.php which contains the database details, db.php also contains:
function GetCartId()
{
if(isset($_COOKIE["cartId"]))
{
return $_COOKIE["cartId"];
}
else
{
session_start();
setcookie("cartId", session_id(), time() + ((3600 * 24) * 30));
return session_id();
}
}
Now this is all in db.php along with the mysql_link and all of that.
db.php is refered to when search results are done, and in cart.php.
Now the coding for cart.php for adding an item is:
$result = mysql_query("select count(*) from cart where cookieId = '" . GetCartId() . "' and itemId = $itemId");
There is also a table called cart which is as follows:
create table cart
(
cartId int auto_increment not null,
cookieId varchar(50),
itemId int,
qty int,
primary key(cartId),
unique id(cartId)
);
Now could someone please explain to me how this setup actually works(im a newbie to this and it will help my understanding and also help in making advances to this setup)?
Many Thanks
ceanth