Warning: Cannot modify header information - headers already sent by (output started at /var/users/modelair/modelaircraft.co.nz/htdocs/cart.php:9) in /var/users/modelair/modelaircraft.co.nz/htdocs/db.php on line 40
Warning: Cannot modify header information - headers already sent by (output started at /var/users/modelair/modelaircraft.co.nz/htdocs/cart.php:9) in /var/users/modelair/modelaircraft.co.nz/htdocs/db.php on line 40
session start is at the top before anything is sent.. is this correct? obvisouly not if im getting errors.
Code: Select all
<?php
session_start()
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Links</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
function UpdateQty(item)
{
itemId = item.name;
newQty = item.options[item.selectedIndex].text;
document.location.href = 'cart.php?action=update_item&id='+itemId+'&qty='+newQty;
}
</script>
</head>
<body onLoad="MM_preloadImages('Website_Pics/Commercial%202.gif','Website_Pics/Famous_Air_Races.gif','Website_Pics/General_Aviation%202.gif','Website_Pics/USAF_Fighters.gif','Website_Pics/Banner_Menu/About%20Us%202.gif','Website_Pics/Banner_Menu/Contact%20Us%202.gif','Website_Pics/Banner_Menu/Custom%202.gif','Website_Pics/Banner_Menu/Order%202.gif','Website_Pics/Banner_Menu/Home%202.gif','Website_Pics/1st_Flight_2.gif','Website_Pics/Commercial_2.gif','Website_Pics/Famous_Air_Races_2.gif','Website_Pics/General_Aviation_2.gif','Website_Pics/Helicopters_2.gif','Website_Pics/NASA_2.gif','Website_Pics/Seaplanes_2.gif','Website_Pics/US_Army_2.gif','Website_Pics/US_Coastguard_2.gif','Website_Pics/US_Marine_Corps_2.gif','Website_Pics/US_Navy_2.gif','Website_Pics/USAF_Fighters_2.gif','Website_Pics/USAF_Jet_Transports_2.gif','Website_Pics/USAF_Piston_2.gif','Website_Pics/Vintage_Commercial_2.gif','Website_Pics/Vintage_Transports_2.gif','Website_Pics/WW_I_2.gif','Website_Pics/WWII_Bombers_2.gif','Website_Pics/WWII_Fighters_2.gif')">
<img src="spacer.gif" width="1" height="1">
<table width="701" align="center" cellpadding="0" cellspacing="0" background="Website_Pics/Background.jpg">
<!--DWLayoutTable-->
<tr>
<td height="1" colspan="3" valign="top" bgcolor="#666666"><img src="spacer.gif" width="1" height="1"></td>
<td width="1"></td>
</tr>
<tr>
<td width="1" rowspan="9" valign="top" bgcolor="#666666"><img src="spacer.gif" width="1" height="1"></td>
<td height="134" colspan="2" align="left" valign="middle"><img src="Website_Pics/Banner.jpg" width="699" height="134"></td>
<td rowspan="9" valign="top" bgcolor="#666666"><img src="spacer.gif" width="1" height="1"></td>
</tr>
<tr>
<td height="1" colspan="2" valign="top" bgcolor="#000000"><img src="spacer.gif" width="1" height="1"></td>
</tr>
<tr>
<td height="19" colspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="234" height="19" valign="top"><!--DWLayoutEmptyCell--> </td>
<td width="45" valign="top"><a href="index.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Home','','Website_Pics/Banner_Menu/Home%202.gif',1)"><img src="Website_Pics/Banner_Menu/Home.gif" name="Home" width="45" height="19" border="0"></a></td>
<td width="3" valign="top"><img src="Website_Pics/Banner_Menu/Space.gif" width="3" height="19"></td>
<td width="61" valign="top"><a href="about_us.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('About','','Website_Pics/Banner_Menu/About%202.gif',1)"><img src="Website_Pics/Banner_Menu/About.gif" name="About" width="61" height="19" border="0"></a></td>
<td width="3" valign="top"><img src="Website_Pics/Banner_Menu/Space.gif" width="3" height="19"></td>
<td width="78" valign="top"><a href="contact_us.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Contact','','Website_Pics/Banner_Menu/Contact%202.gif',1)"><img src="Website_Pics/Banner_Menu/Contact.gif" name="Contact" width="78" height="19" border="0"></a></td>
<td width="3" valign="top"><img src="Website_Pics/Banner_Menu/Space.gif" width="3" height="19"></td>
<td width="124" valign="top"><a href="links.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Links','','Website_Pics/Banner_Menu/Aviation%202.gif',1)"><img src="Website_Pics/Banner_Menu/Aviation.gif" name="Links" width="124" height="19" border="0"></a></td>
<td width="3" valign="top"><img src="Website_Pics/Banner_Menu/Space.gif" width="3" height="19"></td>
<td width="145" valign="top"><a href="cart.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Cart','','Website_Pics/Banner_Menu/Cart%202.gif',1)"><img src="Website_Pics/Banner_Menu/Cart%202.gif" name="Cart" width="180" height="19" border="0"></a></td>
</tr>
</table></td>
</tr>
<tr>
<td height="1" colspan="2" valign="top" bgcolor="#666666"><img src="spacer.gif" width="1" height="1"></td>
</tr>
<tr>
<td width="176" height="21"></td>
<td width="519"></td>
</tr>
<tr>
<td height="519" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="185" height="19" valign="top"><a href="1st_flight.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Menu_1','','Website_Pics/1st_Flight_2.gif',1)"><img src="Website_Pics/1st_Flight.gif" name="Menu_1" width="177" height="19" border="0"></a></td>
</tr>
<tr>
<td height="19" valign="top"><a href="commercial.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Menu_2','','Website_Pics/Commercial_2.gif',1)"><img src="Website_Pics/Commercial.gif" name="Menu_2" width="177" height="19" border="0"></a></td>
</tr>
<tr>
<td height="19" valign="top"><a href="famous_air_races.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Menu_3','','Website_Pics/Famous_Air_Races_2.gif',1)"><img src="Website_Pics/Famous_Air_Races.gif" name="Menu_3" width="177" height="19" border="0"></a></td>
</tr>
<tr>
<td height="19" valign="top"><a href="general_aviation.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Menu_4','','Website_Pics/General_Aviation_2.gif',1)"><img src="Website_Pics/General_Aviation.gif" name="Menu_4" width="177" height="19" border="0"></a></td>
</tr>
<tr>
<td height="19" valign="top"><a href="helicopters.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Menu_5','','Website_Pics/Helicopters_2.gif',1)"><img src="Website_Pics/Helicopters.gif" name="Menu_5" width="177" height="19" border="0"></a></td>
</tr>
<tr>
<td height="19" valign="top"><a href="intl_military.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Menu_6','','Website_Pics/Intl_Military_2.gif',1)"><img src="Website_Pics/Intl_Military.gif" name="Menu_6" width="177" height="19" border="0"></a></td>
</tr>
<tr>
<td height="19" valign="top"><a href="nasa.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Menu_7','','Website_Pics/NASA_2.gif',1)"><img src="Website_Pics/NASA.gif" name="Menu_7" width="177" height="19" border="0"></a></td>
</tr>
<tr>
<td height="19" valign="top"><a href="seaplanes.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Menu_8','','Website_Pics/Seaplanes_2.gif',1)"><img src="Website_Pics/Seaplanes.gif" name="Menu_8" width="177" height="19" border="0"></a></td>
</tr>
<tr>
<td height="19" valign="top"><a href="us_army.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Menu_9','','Website_Pics/US_Army_2.gif',1)"><img src="Website_Pics/US_Army.gif" name="Menu_9" width="177" height="19" border="0"></a></td>
</tr>
<tr>
<td height="19" valign="top"><a href="us_coastguard.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Menu_10','','Website_Pics/US_Coastguard_2.gif',1)"><img src="Website_Pics/US_Coastguard.gif" name="Menu_10" width="177" height="19" border="0"></a></td>
</tr>
<tr>
<td height="19" valign="top"><a href="us_marine_corps.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Menu_11','','Website_Pics/US_Marine_Corps_2.gif',1)"><img src="Website_Pics/US_Marine_Corps.gif" name="Menu_11" width="177" height="19" border="0"></a></td>
</tr>
<tr>
<td height="19" valign="top"><a href="us_navy.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Menu_12','','Website_Pics/US_Navy_2.gif',1)"><img src="Website_Pics/US_Navy.gif" name="Menu_12" width="177" height="19" border="0"></a></td>
</tr>
<tr>
<td height="19" valign="top"><a href="usaf_fighters.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Menu_13','','Website_Pics/USAF_Fighters_2.gif',1)"><img src="Website_Pics/USAF_Fighters.gif" name="Menu_13" width="177" height="19" border="0"></a></td>
</tr>
<tr>
<td height="19" valign="top"><a href="usaf_jet_transports.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Menu_14','','Website_Pics/USAF_Jet_Transports_2.gif',1)"><img src="Website_Pics/USAF_Jet_Transports.gif" name="Menu_14" width="177" height="19" border="0"></a></td>
</tr>
<tr>
<td height="19" valign="top"><a href="usaf_piston.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Menu_15','','Website_Pics/USAF_Piston_2.gif',1)"><img src="Website_Pics/USAF_Piston.gif" name="Menu_15" width="177" height="19" border="0"></a></td>
</tr>
<tr>
<td height="19" valign="top"><a href="vintage_commercial.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Menu_16','','Website_Pics/Vintage_Commercial_2.gif',1)"><img src="Website_Pics/Vintage_Commercial.gif" name="Menu_16" width="177" height="19" border="0"></a></td>
</tr>
<tr>
<td height="19" valign="top"><a href="vintage_transports.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Menu_17','','Website_Pics/Vintage_Transports_2.gif',1)"><img src="Website_Pics/Vintage_Transports.gif" name="Menu_17" width="177" height="19" border="0"></a></td>
</tr>
<tr>
<td height="19" valign="top"><a href="ww_i.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Menu_18','','Website_Pics/WW_I_2.gif',1)"><img src="Website_Pics/WW_I.gif" name="Menu_18" width="177" height="19" border="0"></a></td>
</tr>
<tr>
<td height="19" valign="top"><a href="wwii_bombers.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Menu_19','','Website_Pics/WWII_Bombers_2.gif',1)"><img src="Website_Pics/WWII_Bombers.gif" name="Menu_19" width="177" height="19" border="0"></a></td>
</tr>
<tr>
<td height="19" valign="top"><a href="wwii_fighters.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Menu_20','','Website_Pics/WWII_Fighters_2.gif',1)"><img src="Website_Pics/WWII_Fighters.gif" name="Menu_20" width="177" height="19" border="0"></a></td>
</tr>
</table></td>
<td valign="top"><table width="100%">
<!--DWLayoutTable-->
<tr>
<td height="42" colspan="2" valign="top"><!--DWLayoutEmptyCell--> </td>
</tr>
<tr>
<td width="487" rowspan="2" valign="top"><div align="justify">
<?php
include("db.php");
switch($_GET["action"])
{
case "add_item":
{
AddItem($_GET["id"], $_GET["qty"]);
ShowCart($rs_cart);
break;
}
case "update_item":
{
UpdateItem($_GET["id"], $_GET["qty"]);
ShowCart($rs_cart);
break;
}
case "remove_item":
{
RemoveItem($_GET["id"]);
ShowCart($rs_cart);
break;
}
default:
{
ShowCart($rs_cart);
}
}
function AddItem($itemId, $qty)
{
// Will check whether or not this item
// already exists in the cart table.
// If it does, the UpdateItem function
// will be called instead
// Get a connection to the database
// Check if this item already exists in the users cart table
$result = mysql_query("SELECT count(*) FROM cart WHERE cookieId = '" . GetCartId() . "' AND itemId = $itemId");
$row = mysql_fetch_row($result);
$numRows = $row[0];
if($numRows == 0)
{
// This item doesn't exist in the users cart,
// we will add it with an insert query
@mysql_query("INSERT INTO cart(cookieId, itemId, qty) VALUES('" . GetCartId() . "', $itemId, $qty)");
}
else
{
// This item already exists in the users cart,
// we will update it instead
UpdateItem($itemId, $qty);
}
}
function UpdateItem($itemId, $qty)
{
// Updates the quantity of an item in the users cart.
// If the qutnaity is zero, then RemoveItem will be
// called instead
if($qty == 0)
{
// Remove the item from the users cart
RemoveItem($itemId);
}
else
{
mysql_query("UPDATE cart SET qty = $qty WHERE cookieId = '" . GetCartId() . "' AND itemId = $itemId");
}
}
function RemoveItem($itemId)
{
// Uses an SQL delete statement to remove an item from
// the users cart
mysql_query("DELETE FROM cart WHERE cookieId = '" . GetCartId() . "' AND itemId = $itemId");
}
function ShowCart()
{
// Gets each item from the cart table and display them in
// a tabulated format, as well as a final total for the cart
// Get a connection to the database
$totalCost = 0;
$result = mysql_query("select * from cart inner join planes on cart.itemId = planes.itemId where cart.cookieId = '" . GetCartId() . "' order by planes.P_Name asc");
?>
<table>
<?
while($row = mysql_fetch_array($result))
{
// Increment the total cost of all planes
$totalCost += ($row["qty"] * $row["P_Price"]);
?>
<tr>
<td width="15%" height="25">
<font face="verdana" size="1" color="black">
<select name="<?php echo $row["itemId"]; ?>" onChange="UpdateQty(this)">
<?php
for($i = 1; $i <= 20; $i++)
{
echo "<option ";
if($row["qty"] == $i)
{
echo " SELECTED ";
}
echo ">" . $i . "</option>";
}
?>
</select>
</font>
</td>
<td width="55%" height="25">
<font face="verdana" size="1" color="black">
<?php echo $row["P_Name"]; ?>
</font>
</td>
<td width="20%" height="25">
<font face="verdana" size="1" color="black">
$<?php echo number_format($row["P_Price"], 2, ".", ","); ?>
</font>
</td>
<td width="10%" height="25">
<font face="verdana" size="1" color="black">
<a href="cart.php?action=remove_item&id=<?php echo $row["itemId"]; ?>">Remove</a>
</font>
</td>
</tr>
<?
} //You have to have this read as php
?>
<tr>
<td width="100%" colspan="4">
<hr size="1" color="red" NOSHADE>
</td>
</tr>
<tr>
<td width="70%" colspan="2">
<font face="verdana" size="1" color="black">
<a href="index.php"><< Keep Shopping</a>
</font>
</td>
<td width="30%" colspan="2">
<font face="verdana" size="2" color="black">
<b>Total: $<?php echo number_format($totalCost, 2, ".", ","); ?></b>
</font>
</td>
</tr>
</table>
<?
} //You have to have this read as php
?>
</div></td>
<td width="18" height="182" valign="top"><!--DWLayoutEmptyCell--> </td>
</tr>
<tr>
<td height="31"> </td>
</tr>
<tr>
<td height="252"> </td>
<td> </td>
</tr>
</table></td>
</tr>
<tr>
<td height="17"></td>
<td></td>
</tr>
<tr>
<td height="20" colspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td height="1" colspan="12" valign="top" bgcolor="#666666"><img src="spacer.gif" width="1" height="1"></td>
</tr>
<tr>
<td width="234" height="19" valign="top"><!--DWLayoutEmptyCell--> </td>
<td width="45" valign="top"><a href="index.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Home','','Website_Pics/Banner_Menu/Home%202.gif',1)"><img src="Website_Pics/Banner_Menu/Home.gif" name="Home" width="45" height="19" border="0"></a></td>
<td width="3" valign="top"><img src="Website_Pics/Banner_Menu/Space.gif" width="3" height="19"></td>
<td width="61" valign="top"><a href="about_us.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('About','','Website_Pics/Banner_Menu/About%202.gif',1)"><img src="Website_Pics/Banner_Menu/About.gif" name="About" width="61" height="19" border="0"></a></td>
<td width="3" valign="top"><img src="Website_Pics/Banner_Menu/Space.gif" width="3" height="19"></td>
<td width="78" valign="top"><a href="contact_us.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Contact','','Website_Pics/Banner_Menu/Contact%202.gif',1)"><img src="Website_Pics/Banner_Menu/Contact.gif" name="Contact" width="78" height="19" border="0"></a></td>
<td width="3" valign="top"><img src="Website_Pics/Banner_Menu/Space.gif" width="3" height="19"></td>
<td width="124" valign="top"><a href="links.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Links','','Website_Pics/Banner_Menu/Aviation%202.gif',1)"><img src="Website_Pics/Banner_Menu/Aviation.gif" name="Links" width="124" height="19" border="0"></a></td>
<td width="3" valign="top"><img src="Website_Pics/Banner_Menu/Space.gif" width="3" height="19"></td>
<td width="145" valign="top"><a href="cart.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Cart','','Website_Pics/Banner_Menu/Cart%202.gif',1)"><img src="Website_Pics/Banner_Menu/Cart%202.gif" name="Cart" width="180" height="19" border="0"></a></td>
</tr>
</table></td>
</tr>
<tr>
<td height='1' colspan='2' valign='top' bgcolor='#666666'><img src='spacer.gif' width="1" height="1"></td>
</tr>
</table>
</body>
</html>