empty cart function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
C_Calav
Forum Contributor
Posts: 395
Joined: Wed Jun 02, 2004 10:55 pm
Location: New Zealand

empty cart function

Post by C_Calav »

hi guys. im getting a bit stuck at making a empty cart function where i delete all items out of the cart for that user.

am i sending the right info? im not sure which attribute to use for the user.

if anyone could help me out that would be great!

thanx, Chris

here is my cart table

[mysql_man]
create table cart
(
cartId int auto_increment not null,
cookieId varchar(50),
itemId int,
qty int,
primary key(cartId),
unique id(cartId)
);
[/mysql_man]

here are my functions

Code: Select all

<?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; 
      } 
	  case "empty_cart": 
      { 
         EmptyCart($_GET["id"]);     
         ShowCart($rs_cart); 
         break; 
      } 
      default: 
      { 
         ShowCart($rs_cart); 
      } 
   } 
?>

Code: Select all

<?php
function RemoveItem($itemId) 
{ 
      mysql_query("DELETE FROM cart WHERE cookieId = '" . GetCartId() . "' AND itemId = $itemId"); 
} 
    
function EmptyCart($itemId) 
{ 
      mysql_query("DELETE FROM cart WHERE cookieId = '" . GetCartId() ."'"); 
} 
?>
here is my button

Code: Select all

&lt;input type="submit" value="Reset"  onclick="form.action='cart.php?action=empty_cart'" class="button" /&gt;
User avatar
thomas777neo
Forum Contributor
Posts: 214
Joined: Mon Mar 10, 2003 6:12 am
Location: Johannesburg,South Africa

Suggestion

Post by thomas777neo »

Regarding your code:

Code: Select all

function EmptyCart($itemId) &#123;       mysql_query("DELETE FROM cart WHERE cookieId = '" . GetCartId() ."'"); &#125;
Shouldn't it look something like this:

Code: Select all

function EmptyCart($itemId) &#123;       mysql_query("DELETE FROM cart WHERE cookieId = '$itemId'"); &#125;
Where you you get the value for

Code: Select all

cookieId = '" . GetCartId() ."'
.

I think your problem lies here.
User avatar
C_Calav
Forum Contributor
Posts: 395
Joined: Wed Jun 02, 2004 10:55 pm
Location: New Zealand

Post by C_Calav »

thanx thomas777neo for your help. i have changed the code accordingly. was that all i needed to change? it still does nothing when i click the button.

also i do not understand what you mean by this though:
Where you you get the value for Code:
cookieId = '" . GetCartId() ."'
.
thanx, Chris

function looks like this now:

Code: Select all

function EmptyCart($itemId) 
	&#123;       
		mysql_query("DELETE FROM cart WHERE cookieId = '$itemId'"); 
	&#125;
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

what does your query look like

Post by phpScott »

Code: Select all

<?php

function RemoveItem($itemId) 
{ 
$query= "DELETE FROM cart WHERE cookieId = '" . GetCartId() . "' AND itemId = $itemId";
echo "query is $query<br />";
 mysql_query($query); 
 
} 
    
function EmptyCart($itemId) 
{ 
      $query="DELETE FROM cart WHERE cookieId = '" . GetCartId() ."'";
echo "query is $query<br />";
 mysql_query($query); 
} 

?>
to see what your query is and to make sure it is correct is probably the easest way to make sure your queries are doing what you ask.

do any of your other functions work?
User avatar
C_Calav
Forum Contributor
Posts: 395
Joined: Wed Jun 02, 2004 10:55 pm
Location: New Zealand

Post by C_Calav »

thanx phpScott, i will try that when i get home! good tip for future coding.

all the other functions work great. i just added that one at the end as i need to empty my cart.
User avatar
C_Calav
Forum Contributor
Posts: 395
Joined: Wed Jun 02, 2004 10:55 pm
Location: New Zealand

Post by C_Calav »

can someone please help me with what the sql is too delete all from cart for that user?

phpScott: i have used

Code: Select all

echo "query is $query<br />";
and it is returing nothing trying it with both querys below.

im not sure weather the correct query is

Code: Select all

mysql_query("DELETE FROM cart WHERE cookieId = '" . GetCartId() ."'");
or

Code: Select all

mysql_query("DELETE FROM cart WHERE cookieId = '$itemId'");
i thought it would be "delete * from cart where cart id = $cartid" or something along these lines.

can anyone help me?

thanx, Chris
User avatar
C_Calav
Forum Contributor
Posts: 395
Joined: Wed Jun 02, 2004 10:55 pm
Location: New Zealand

Post by C_Calav »

thomas777neo i tried ur help and it does not return anything?

is this the right code to write for the button to go to the empty cart function?

Code: Select all

&lt;input type="submit" value="Reset"  onclick="form.action='cart.php?action=empty_cart'" class="button" /&gt;
this is what i have so far:

Code: Select all

<?php
 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 EmptyCart($itemId) 
	{       
	
	      $query="DELETE * FROM cart WHERE cookieId = $cartId";
		  echo "query is $query<br />"; 
		  mysql_query($query); 
		
	}
?>
i have

Code: Select all

<?php echo "cartid is $cartId"; <br /> ?>
to check the cartid later on in the page and it is giving me the correct number i need to delete all items from cart.

it does not work anyone see anything wrong?
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post by phpScott »

ichange

Code: Select all

<?php
function EmptyCart($itemId) 
    {       
          $query="DELETE * FROM cart WHERE cookieId = $cartId";
          echo "query is $query<br />"; 
          mysql_query($query); 
        
    }
?>
to

Code: Select all

<?php
function EmptyCart($itemId) 
    {       
          $query="DELETE * FROM cart WHERE cookieId = $itemId";
          echo "query is $query<br />"; 
          mysql_query($query); 
        
    }
?>
providing that $itemId is the cookieId that you want to use.
User avatar
C_Calav
Forum Contributor
Posts: 395
Joined: Wed Jun 02, 2004 10:55 pm
Location: New Zealand

Post by C_Calav »

thanx for the reply phpScott,

but isnt $itemId for the item and $cartId for the cart?

i did <?php echo "cartid is $cartId"; <br /> ?> and this returns the correct cookieId everytime?

im no expert, this is just what i have found. im pretty sure i have tried your way the first time, but will try again when i get home from work.

also, echo "query is $query<br />"; , in your code does not print anything once the button is pressed, it just prints the "query is" then nothing.

your advice is much appreciated!
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post by phpScott »

the problem with your EmptyCart() function is that you pass in $itemId then use $cartId in your query.
Do to variable scoping you EmptyCart function has no idea what $cartId is only what $itemId is. You have to change one variable name or the other to what you want.

The other thing is do you have your display_errors=on in your php.ini file because I'm pretty sure that should have come up as a warning.
User avatar
C_Calav
Forum Contributor
Posts: 395
Joined: Wed Jun 02, 2004 10:55 pm
Location: New Zealand

Post by C_Calav »

ah i see, thanx phpScott again, will change tomorow now bit late and got work in morning. Cheers!
User avatar
C_Calav
Forum Contributor
Posts: 395
Joined: Wed Jun 02, 2004 10:55 pm
Location: New Zealand

Post by C_Calav »

hi,

phpScott, i did what you said and passed $cartId (or use two of the same vairables) into the function and still not work, nothing happening or getting displayed.

can you or anyone see anything else that i am doing wrong?

thanx heaps!

Code: Select all

<?phpsession_start(); 

// This page contains the connection routine for the 
// database as well as getting the ID of the cart, etc 
 $db = mysql_pconnect(****) or die ("Could not connect to database");

    if (!$db)
    {
     echo 'Error: Could not connect to database.  Please try again laterrrrrr.';
     exit;
    }

    mysql_select_db('models') or die ("Could not select database!"); 

function ConnectToDb($server, $user, $pass, $database) 
{ 
// Connect to the database and return 
// true/false depending on whether or 
// not a connection could be made. 
$s = @mysql_connect($server, $user, $pass); 
$d = @mysql_select_db($database, $s); 
if(!$s || !$d) 
return false; 
else 
return true; 
} 
function GetCartId() 
{ 
// This function will generate an encrypted string and 
// will set it as a cookie using set_cookie. This will 
// also be used as the cookieId field in the cart table 
if(isset($_COOKIE["cartId"])) 
{ 
return $_COOKIE["cartId"]; 
} 
else 
{ 
// There is no cookie set. We will set the cookie 
// and return the value of the users session ID 
setcookie("cartId", session_id(), time() + ((3600 * 24) * 30)); 
return session_id(); 
} 
} 

    $db = mysql_pconnect('db.iserve.net.nz', 'chris', 'cessna') or die ("Could not connect to database");

    if (!$db)
    {
     echo 'Error: Could not connect to database.  Please try again laterrrrrr.';
     exit;
    }

    mysql_select_db('models') or die ("Could not select database!"); 

   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; 
      } 
	  case "empty_cart": 
      { 
         EmptyCart($_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 EmptyCart($cartId) 
	{       
	
	      $query="DELETE * FROM cart WHERE cookieId = $cartId";
		  echo "query is $query<br />"; 
		  mysql_query($query); 
		
	}
	
   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");   

?>

Code: Select all

&lt;div align="center"&gt;
&lt;form name="cart" action=""&gt; 
&lt;input type="submit" value="Reset"  onclick="form.action='cart.php?action=empty_cart'" class="button" /&gt; 
&lt;input type="submit" value="Continue" onclick="form.action='details.php'" class="button" /&gt; 
&lt;/form&gt;
&lt;/div&gt;
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post by phpScott »

explictly set your form method="GET" because that is what you are using to retrieve the variable in your code $_GET['action'];

echo out your action, id and any thing else you are trying to pass to your empty cart function at the top of the page to make sure that you are getting values you are expecting.

then keep echoing them out at every stage to make sure that they are reaching the function correctly. Or even if the function is getting called.
Look closley for typos and capitilization as that can cause things to go off.

Let me know what happens.
User avatar
C_Calav
Forum Contributor
Posts: 395
Joined: Wed Jun 02, 2004 10:55 pm
Location: New Zealand

Post by C_Calav »

awsome. thanx phpScott will get on to it tomorow, got wrk in morning. fixed up those css errors too, thanx.
User avatar
C_Calav
Forum Contributor
Posts: 395
Joined: Wed Jun 02, 2004 10:55 pm
Location: New Zealand

Post by C_Calav »

hi phpScott,

ok.. i have looked at the code more closey. the sql work as i tested it on mySQL, and i added in the method get.

i also added

Code: Select all

&lt;a href="cart.php?action=empty_cart"&gt;-Empty-&lt;/a&gt;
this on my webpage. this link works and emptys the cart like i want! so thats a good thing! but putting this code into a button instead of a hyper link
is where its tripping up.

but my problem is, i dont think it is reaching the empty_cart function and im not sure why. all the other functions work.

here is my code comeplete for you or anyone to have a look at. i dont know how to get the button to work and call the function.

thanx guys and thanx phpScott for all your help!

Code: Select all

<?php
session_start(); 

// This page contains the connection routine for the 
// database as well as getting the ID of the cart, etc 
 $db = mysql_pconnect(***) or die ("Could not connect to database");

    if (!$db)
    {
     echo 'Error: Could not connect to database.  Please try again laterrrrrr.';
     exit;
    }

    mysql_select_db('models') or die ("Could not select database!"); 

function ConnectToDb($server, $user, $pass, $database) 
{ 
// Connect to the database and return 
// true/false depending on whether or 
// not a connection could be made. 
$s = @mysql_connect($server, $user, $pass); 
$d = @mysql_select_db($database, $s); 
if(!$s || !$d) 
return false; 
else 
return true; 
} 
function GetCartId() 
{ 
// This function will generate an encrypted string and 
// will set it as a cookie using set_cookie. This will 
// also be used as the cookieId field in the cart table 
if(isset($_COOKIE["cartId"])) 
{ 
return $_COOKIE["cartId"]; 
} 
else 
{ 
// There is no cookie set. We will set the cookie 
// and return the value of the users session ID 
setcookie("cartId", session_id(), time() + ((3600 * 24) * 30)); 
return session_id(); 
} 
} 




    $db = mysql_pconnect('db.iserve.net.nz', 'chris', 'cessna') or die ("Could not connect to database");

    if (!$db)
    {
     echo 'Error: Could not connect to database.  Please try again laterrrrrr.';
     exit;
    }

    mysql_select_db('models') or die ("Could not select database!"); 


        
   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; 
      } 
	  case "empty_cart": 
      { 
         EmptyCart();     
         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 
	  
	  $query="DELETE FROM cart WHERE cookieId = '" . GetCartId() . "' AND itemId = $itemId"; 
	  echo "query is $query<br />"; 
	  mysql_query($query); 
		  
     // mysql_query("DELETE FROM cart WHERE cookieId = '" . GetCartId() . "' AND itemId = $itemId"); 
   } 
    
	function EmptyCart()
	{       
	
	      $query="DELETE FROM cart WHERE cookieId = '" . GetCartId() . "'";
		  echo "query is $query<br />"; 
		  mysql_query($query); 
		
	}
	
   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");   
?>

Code: Select all

&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Model Aircraft&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
&lt;style type="text/css" media="all"&gt;

		@import "/css/cart.css";
	&lt;/style&gt;


		&lt;script type="text/javascript"&gt;
		&lt;!--
		function getWindowHeight() &#123;
			var windowHeight = 0;
			if (typeof(window.innerHeight) == 'number') &#123;
				windowHeight = window.innerHeight;
			&#125;
			else &#123;
				if (document.documentElement &amp;&amp; document.documentElement.clientHeight) &#123;
					windowHeight = document.documentElement.clientHeight;
				&#125;
				else &#123;
					if (document.body &amp;&amp; document.body.clientHeight) &#123;
						windowHeight = document.body.clientHeight;
					&#125;
				&#125;
			&#125;
			return windowHeight;
		&#125;
		function setFooter() &#123;
			if (document.getElementById) &#123;
				var windowHeight = getWindowHeight();
				if (windowHeight &gt; 0) &#123;
					var contentHeight = document.getElementById('container').offsetHeight;
					var footerElement = document.getElementById('footer');
					var footerHeight  = footerElement.offsetHeight;
					if (windowHeight - (contentHeight + footerHeight) &gt;= 0) &#123;
						footerElement.style.position = 'relative';
						footerElement.style.top = (windowHeight - (contentHeight + footerHeight)) + 'px';
					&#125;
					else &#123;
						footerElement.style.position = 'static';
					&#125;
				&#125;
			&#125;
		&#125;
		window.onload = function() &#123;
			setFooter();
		&#125;
		window.onresize = function() &#123;
			setFooter();
		&#125;
		
function UpdateQty(item) 
&#123; 
itemId = item.name; 
newQty = item.options&#1111;item.selectedIndex].text; 

document.location.href = 'cart.php?action=update_item&amp;id='+itemId+'&amp;qty='+newQty; 
&#125; 

		//--&gt;
		&lt;/script&gt;

&lt;/head&gt;

&lt;body&gt;


&lt;div id="container"&gt;&lt;h1&gt;Models&lt;/h1&gt;

&lt;!-- Begin Nav center --&gt;
&lt;div id="navcenter"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="/index.php"&gt;Home&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/about.php"&gt;About&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/contact.php"&gt;Contact&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/examples.php"&gt;Examples&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/cart.php" id="current"&gt;Shopping Cart&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt; 
&lt;!-- End Nav Center --&gt;

&lt;!-- Begin LEFT --&gt;
&lt;div id="left"&gt;

&lt;!-- Begin navigation --&gt;
&lt;div id="navcontainer"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="/1st_flight.php"&gt;1st Flight&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/commercial.php"&gt;Commercial&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;Famous Air Races&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;General Aviation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;Helicopters&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;Intl Military&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;NASA Craft&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;Seaplanes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;US Army&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;US Coastguard&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;US Marine Coprps&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;US Navy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;USAF Fighters&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;USAF Piston&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;Vintage Commercial&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;Vintage Transport&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;WWI Aircraft&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;WWI Bombers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;WWII Fighters&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;!-- End navigation --&gt;

&lt;/div&gt;
&lt;!-- End LEFT --&gt;
  


 &lt;!-- start content --&gt;
&lt;div id="content"&gt; 

&lt;p class="text"&gt;
      &lt;table width="500"&gt;
        &lt;!--DWLayoutTable--&gt;
        &lt;tr&gt; 
          &lt;td width="92" height="40" valign="top"&gt;&lt;strong&gt;Aircraft&lt;/strong&gt;&lt;/td&gt;
          &lt;td width="105" valign="top"&gt;&lt;strong&gt;Name&lt;/strong&gt;&lt;/td&gt;
          &lt;td width="57" valign="top"&gt;&lt;strong&gt;Price Ea&lt;/strong&gt;&lt;/td&gt;
          &lt;td colspan="2" valign="top"&gt;&lt;strong&gt;Qty&lt;/strong&gt;&lt;/td&gt;
          &lt;td width="65" valign="top"&gt;&lt;strong&gt;Sub-Total&lt;/strong&gt;&lt;/td&gt;
          &lt;td width="82" valign="top"&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;!--DWLayoutTable--&gt;
        &lt;? 
     while($row = mysql_fetch_array($result))
     &#123; 
     // Increment the total cost of all planes 
     $totalCost += ($row&#1111;"qty"] * $row&#1111;"P_Price"]); 
     ?&gt;
        &lt;tr&gt; 
          &lt;td height="64" valign="top"&gt;&lt;img src=./pics/&lt;?php echo $row&#1111;"P_Stock"];?&gt;.jpg alt="image of plane" width="82" height="62" class="planeimage" /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $row&#1111;"P_Name"]; ?&gt;&lt;/td&gt;
          &lt;td&gt;$&lt;?php echo number_format($row&#1111;"P_Price"], 2, ".", ","); ?&gt;&lt;/td&gt;
          &lt;td colspan="2"&gt;&lt;select name="&lt;?php echo $row&#1111;"itemId"]; ?&gt;" onChange="UpdateQty(this)"&gt;
              &lt;?php 
      for($i = 1; $i &lt;= 20; $i++) 
      &#123; 
      echo "&lt;option "; 
      if($row&#1111;"qty"] == $i) 
      &#123; 
      echo " SELECTED "; 
      &#125; 
      echo "&gt;" . $i . "&lt;/option&gt;"; 
      &#125; 
      ?&gt;
            &lt;/select&gt;&lt;/td&gt;
          &lt;td&gt; 
            $&lt;?php $row&#1111;"subtotal"] = ($row&#1111;"qty"] * $row&#1111;"P_Price"]); echo number_format($row&#1111;"subtotal"], 2, ".", ","); ?&gt;
          &lt;/td&gt;
          &lt;td valign="center"&gt;&lt;div align="center"&gt;&lt;a href="cart.php?action=remove_item&amp;id=&lt;?php echo $row&#1111;"itemId"]; ?&gt;"&gt;Remove&lt;/a&gt; 
            &lt;/div&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt; 
          &lt;td height="21" colspan="7" valign="center"&gt;&lt;hr size="1" color="#666666" NOSHADE /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;? 
      	&#125; //You have to have this read as php 
      ?&gt;
        &lt;!--DWLayoutTable--&gt;
        &lt;tr&gt; 
          &lt;td height="21" colspan="4" valign="top"&gt;&lt;a href=1st_flight.php&gt;Continue 
            Shopping&lt;/a&gt;&lt;/td&gt;
          &lt;td width="45" valign="top"&gt;&lt;strong&gt;Total: &lt;/strong&gt;&lt;/td&gt;
          &lt;td colspan="2" valign="top"&gt;$&lt;?php echo number_format($totalCost, 2, ".", ","); ?&gt; 
          &lt;/td&gt;
        &lt;/tr&gt;
      &lt;/table&gt;

	 &lt;? 
      	&#125; //You have to have this read as php 
     ?&gt;

&lt;br /&gt;

&lt;?php echo "cartid is $cartId"; ?&gt;&lt;br /&gt;

&lt;br /&gt;
&lt;br /&gt;
&lt;div align="center"&gt;
&lt;form name="cart" method="GET" action=""&gt; 
&lt;input type="submit" value="Reset"  onclick="form.action='cart.php?action=empty_cart'" class="button" /&gt; 
&lt;input type="submit" value="Continue" onclick="form.action='details.php'" class="button" /&gt; 
&lt;/form&gt;
&lt;/div&gt;
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- End Content --&gt;

&lt;/div&gt;

&lt;!-- Begin Footer --&gt;
&lt;div id="footer"&gt; 
	&lt;h3&gt;copyright &amp;copy; 2004 Model Aircraft&lt;/h3&gt;
&lt;/div&gt;
&lt;!-- End Footer --&gt;


&lt;/body&gt;

&lt;/html&gt;
Post Reply