Jump to content

Need help with Shopping cart!!!


ycoleman

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...

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.