Hi people

I have a basic shopping cart here, taken from a book "Build Your Own Database Driven Web Site Using PHP & MySQL"

basic catalogue

<?php
session_start();
if (!isset($_SESSION['cart'])) {
	$_SESSION['cart'] = array();
}
if (isset($_GET['buy'])) {
	// Add item to the end of the $_SESSION['cart'] array
	$_SESSION['cart'][] = $_GET['buy'];
	header('location: ' . $_SERVER['PHP_SELF'] . '?' . SID);
	exit();
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Product catalog</title>
<meta http-equiv="content-type"
	content="text/html; charset=iso-8859-1" />
</head>
<body>
<p>Your shopping cart contains <?php
	echo count($_SESSION['cart']); ?> items.</p>
<?php
$items = array(
	'Canadian-Australian Dictionary',
	'As-new parachute (never opened)',
	'Songs of the Goldfish (2CD Set)',
	'Ending PHP4 (O\'Wroxey Press)');
$prices = array(24.95, 33.95, 19.99, 34.95);
?>
<table border="1">
	<thead>
		<tr>
			<th>Item Description</th>
			<th>Price</th>
		</tr>
	</thead>
<tbody>
<?php
	for ($i = 0; $i < count($items); $i++) {
		echo '<tr>';
		echo '<td>' . $items[$i] . '</td>';
		echo '<td>$' . number_format($prices[$i], 2) . '</td>';
		echo '<td><a href="' . $_SERVER['PHP_SELF'] .
			'?buy=' . $i . '">Buy</a></td>';
		echo '</tr>';
}
	?>
	</tbody>
</table>
<p><a href="cart.php">View your cart</a></p>
</body>
</html>

and basket

<?php
session_start();
if (!isset($_SESSION['cart'])) {
	$_SESSION['cart'] = array();
}
if (isset($_GET['empty'])) {
	unset($_SESSION['cart']);
	header('location: ' . $_SERVER['PHP_SELF'] . '?' . SID);
	exit();
}
if (isset($_GET['delete'])) {
 $delete = $_GET['delete'];
array_splice($_SESSION['cart'], $delete, 1);
header('location: ' . $_SERVER['PHP_SELF'] . '?' . SID);
exit();
}
?>







<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Shopping cart</title>
<meta http-equiv="content-type"
	content="text/html; charset=iso-8859-1" />
</head>
<body>
<h1>Your Shopping Cart</h1>
<?php
$items = array(
	'Canadian-Australian Dictionary',
	'As-new parachute (never opened)',
	'Songs of the Goldfish (2CD Set)',
	'Ending PHP4 (O\'Wroxey Press)');
$prices = array( 24.95, 33.95, 19.99, 34.95 );
$shipping = array( 1.95 );
?>
<table border="1">
	<thead>
		<tr>
			<th>Item Description</th>
			<th>Price</th>
		</tr>
	</thead>
<tbody>
<?php
	$total = 0;
	for ($i = 0; $i < count($_SESSION['cart']); $i++) {
			echo '<tr>';
			echo "<td><div align='center'><a href=\"$PHPSELF?delete=$i\">Delete</a>";							
			echo '<td>' . $items[$_SESSION['cart'][$i]] . '</td>';
			echo '<td align="right">$';
			echo number_format($prices[$_SESSION['cart'][$i]], 2);
			echo '</td>';
			echo '</tr>';
			$total = $total + $prices[$_SESSION['cart'][$i]];

}
?>
</tbody>
<tfoot>
    <tr>
		<th align="right"></th><br>
		<th align="right">Total: $<?php echo number_format($total, 2); ?>
    </th>
</tr>
</tfoot>
</table>







<p><a href="catalog.php">Continue Shopping</a> or
<a href="<?php echo $_SERVER['PHP_SELF']; ?>?empty=1">Empty your
	cart</a></p>
    

</body>
</html>

what i'd like to do is to send the data which is stored in the array (items and total cost) via email.when added to the cart
fairly new at this but what I gather, it should be rather simple, kinda urgent I figure this out :(, pulling my hair out

here's a link to this online if it helps - http://localhost/webcart/catalog.php

u need to use the list() function

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.