Help developing cart
Posted: Thu Nov 06, 2008 7:19 am
Hi all,
Im new to PHP and sql and so I am using a premade simple php cart:
http://www.thewatchmakerproject.com/jou ... pping-cart
I am beggining to understand how it works but I need to improve on the existing cart, within the various part of code I insert the following into my site to select all the entries in my database:
This then prodces a link which when clicked passes the id number of the particular item to the cart.php page:
I have a couple of questions, firstly what is the above function called so I can read further into it to help my understanding.
Secondly would it be possible to send the id as well as the corresponding price information so that I could have a particular item with three prices, in this case three different sizes of pizza, so that the cart.php page would add the correct price for the correct size without having to list three seperate database entries for one type of pizza.
Please forgive me if this is a newbie question but I am still fairly new to Php and sql.
Any help is much appreciated. Thanks in advance.
Im new to PHP and sql and so I am using a premade simple php cart:
http://www.thewatchmakerproject.com/jou ... pping-cart
I am beggining to understand how it works but I need to improve on the existing cart, within the various part of code I insert the following into my site to select all the entries in my database:
Code: Select all
<?php
$sql = 'SELECT * FROM salads ORDER BY id';
$result = $db->query($sql);
$output[] = '<ul>';
while ($row = $result->fetch()) {
$output[] = '<li>'.$row['name'].': £'.$row['price'].'<br /><a href="cart.php?action=add&id='.$row['id'].'">Add to cart</a></li>';
}
$output[] = '</ul>';
echo join('',$output);
?>
Code: Select all
<a href="cart.php?action=add&id='.$row['id'].'">Add to cart</a>Secondly would it be possible to send the id as well as the corresponding price information so that I could have a particular item with three prices, in this case three different sizes of pizza, so that the cart.php page would add the correct price for the correct size without having to list three seperate database entries for one type of pizza.
Please forgive me if this is a newbie question but I am still fairly new to Php and sql.
Any help is much appreciated. Thanks in advance.