I am wanting to build a very simple "shopping cart". I have all of the code written for the catalog, adding products, categories, etc... The only thing I need now is a shopping cart to add the items to.
Right now, after you search for your products, it takes you to a page, with a list of products ... all from a mysql db.
I don't want to deal with users, just a way to add the products to the cart, and then it will take them to a form to enter their information for each order.
I dont know whether to use sessions or cookies. Does anyone know what the easiest way to do it would be?
Here is the code for the final product selection, where you can select the products... I guess I just need a button that will add it to the cart. Then the user can checkout and then all info is stored in a session or cookie. Does anyone have any sample code for starting a session or using cookies. A simple example would be great...maybe just adding something to the session etc...
<table width="100%" border="0" cellspacing="3" cellpadding="0">
<tr>
<td width="45%"><strong><font color="#999966" size="2" face="Arial, Helvetica, sans-serif">
<?php
// DB CONNECTION
include( "_secure.php");
$db = mysql_connect( $mysql_server, $mysql_name, $mysql_password);
mysql_select_db($mysql_db, $db);
?>
</font></strong>
<?php
$result = mysql_query("SELECT * FROM packages WHERE id='$id' ORDER BY package");
while ($myrow = mysql_fetch_array($result)) {
print ("<img src=images/$myrow[file_name] width=250 border=0>");
}
?>
</td>
<td width="55%" valign="top"> <strong><font size="2" face="Arial, Helvetica, sans-serif">Description:</font></strong>
<?php
$result = mysql_query("SELECT * FROM packages WHERE id='$id' ORDER BY package");
while ($myrow = mysql_fetch_array($result)) {
print ("<font size=2 face=Arial, Helvetica, sans-serif>$myrow[description]");
}
?>
</td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2"><font size="2" face="Arial, Helvetica, sans-serif"><strong><u>Party
Package Items:</u></strong></font></td>
</tr>
<tr>
<td height="58" colspan="2"><table width="100%" border="0" cellspacing="2" cellpadding="0">
<tr>
<td width="14%">
<?
$result = mysql_query("SELECT * FROM packages WHERE id='$id'");
while ($myrow = mysql_fetch_array($result)) {
$package=$myrow[package];
}
?>
</td>
<td width="12%"><strong><font size="2" face="Arial, Helvetica, sans-serif">Part
#</font></strong></td>
<td width="49%"><strong><font size="2" face="Arial, Helvetica, sans-serif">Item</font></strong></td>
<td width="13%"><strong><font size="2" face="Arial, Helvetica, sans-serif">Price</font></strong></td>
<td width="12%"><div align="center"><strong><font size="2" face="Arial, Helvetica, sans-serif">Quantity</font></strong></div></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="3" cellpadding="0">
<?
$result = mysql_query("SELECT * FROM package_items WHERE package='$package'");
while ($myrow = mysql_fetch_array($result)) {
print(" <tr>
<td width=14%><font size=2 face=Arial, Helvetica, sans-serif> <input name=View type=image src=images/$myrow[file_name] width=50 onClick=MM_openBrWindow('packages_next3.php?id=$myrow[id]','','toolbar=no,scrollbars=yes,width=600,height=400') value=View></td>
<td width=12%><font size=2 face=Arial, Helvetica, sans-serif> $myrow[part]</td>
<td width=49%><font size=2 face=Arial, Helvetica, sans-serif> $myrow[item]</td>
<td width=13%><font size=2 face=Arial, Helvetica, sans-serif> $$myrow[price]</td>
<td width=12%><div align=center><font size=2 face=Arial, Helvetica, sans-serif> <input name=quantity type=text size=3 maxlength=3></div></td>
</tr>");
}
?>
</table></td>
</tr>
<tr>
<td colspan="2"><div align="right">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="98%"><div align="right">
<input type="submit" name="Submit" value="Order">
</div></td>
<td width="2%"> </td>
</tr>
</table>
</div></td>
</tr>
</table>