Jump to content

Recommended Posts

I am trying to create a shopping cart for my toy store website I am not sure where to start.  Can somebody help me????

 

hello, firstly, do not use !!!!!! in the title, it's kinda rude.

secondly, provide more information:

can you code php or are you actually looking for a cart package to install?

 

 

either way, grab this book How to Do Everything With PHP and MySQL

 

Chapter 7

Sample

Application:

Session-Based

Shopping Cart

 

unless you have more specific question, it's difficult to help you.

All I'm asking is how to create a shopping cart,  I didn't ask for any sarcastic replies.  What is the point of you guys having this forum and you can't help anybody.  If you don't have the anwser to my question or any resources I can go too then don't post anything!!  I have tried many ways to and looked everywhere fopr guidance on how to do these functions, but I'm only asking nicely.  I am not looking for you guys to do it for me, just give me some examples like you guys gave the other users.  >:(

All I'm asking is how to create a shopping cart,  I didn't ask for any sarcastic replies.  What is the point of you guys having this forum and you can't help anybody.  If you don't have the anwser to my question or any resources I can go too then don't post anything!!  I have tried many ways to and looked everywhere fopr guidance on how to do these functions, but I'm only asking nicely.  I am not looking for you guys to do it for me, just give me some examples like you guys gave the other users.  >:(

 

look in my signature and read everything under the category 'basic'. everything. then, hit the forums. we cannot/will not help you unless you are willing to help yourself.

Thank you guys for the resources to my questions.  I went to the "Building a simple PHP shopping cart" site"  and I typed in the code in but I get a parse error in line 124 which is where the $total variable is located:  Did I forget something or did I put one too many brackets?

 

Here is the code I have so far:

 

 

	  
<?php 

$_SESSION['cart'] ='tblProduct';

function writeShoppingCart() {
$cart = $_SESSION['cart'];
if (!$cart) {
	return '<p>You have no items in your shopping cart</p>';
} else {
	// Parse the cart session variable
	$items = explode(',',$cart);
	$s = (count($items) > 1) ? 's':'';
	return '<p>You have <a href="shoppingCart.php">'.count($items).' item'.$s.' in your shopping cart</a></p>';

$cart = $_SESSION['cart']; 


total = 0; 
$output[] = '<table>'; 
foreach ($contents as $id=>$qty) { 
$sql = 'SELECT * FROM tblProduct WHERE ID = '.$id; 
$result = $db->query($sql); 
$row = $result->fetch(); 
extract($row); 
$output[] = '<tr>'; 
$output[] = '<td><a href="shoppingCart.php?action=delete&id='.$id.'" class="r">Remove</a></td>'; 
$output[] = '<td>'.$title.' by '.$author.'</td>'; 
$output[] = '<td>£'.$price.'</td>'; 
$output[] = '<td><input type="text" name="qty'.$id.'" value="'.$qty.'" size="3" maxlength="3" /></td>'; 
$output[] = '<td>£'.($price * $qty).'</td>'; 
$total += $price * $qty; 
$output[] = '</tr>'; 
} 
$output[] = '</table>'; 
$output[] = '<p>Grand total: £'.$total.'</p>'; 


}

echo writeShoppingCart(); 

}
?>

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.