Page 1 of 1

display shopping cart help

Posted: Sun Jul 25, 2004 1:18 am
by C_Calav
hi guys again,

following this shopping cart tutorial still and have come up to another error.

Parse error: parse error, unexpected T_VARIABLE, expecting '{' in /var/users/modelair/modelaircraft.co.nz/htdocs/cart.php on line 33


also can i take the javascript part out for now? or is that not possiable ie needs it to function. all its doing is updating the qty on the show cart page.

Code: Select all

<?php

include("db.php"); 

switch($_GET["action"]) 
{ 
case "add_item": 
{ 
AddItem($_GET["id"], $_GET["qty"]); 
ShowCart(); 
break; 
} 
case "update_item": 
{ 
UpdateItem($_GET["id"], $_GET["qty"]); 
ShowCart(); 
break; 
} 
case "remove_item": 
{ 
RemoveItem($_GET["id"]); 
ShowCart(); 
break; 
} 
default: 
{ 
ShowCart(); 
} 
} 

function AddItem($itemId, $qty) 

$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); 
} 
mysql_query("update cart set qty = $qty where cookieId = '" . GetCartId() . "' and itemId = $itemId"); 

function RemoveItem($itemId) 

mysql_query("delete from cart where cookieId = '" . GetCartId() . "' and itemId = $itemId"); 


$result = mysql_query("select * from cart inner join items on cart.itemId = items.itemId where cart.cookieId = '" . GetCartId() . "' order by items.itemName asc");

while($row = mysql_fetch_array($result)) 
{ 
// Increment the total cost of all items 
$totalCost += ($row["qty"] * $row["itemPrice"]); 
?> 
<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["itemName"]; ?> 
</font> 
</td> 
<td width="20%" height="25"> 
<font face="verdana" size="1" color="black"> 
$<?php echo number_format($row["itemPrice"], 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> 
<?php 
} 

// Increment the total cost of all items 
$totalCost += ($row["qty"] * $row["itemPrice"]); 

$totalCost = $totalCost + ($row["qty"] * $row["itemPrice"]); 

<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> 

<script language="JavaScript"> 

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> 

<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="products.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>

Posted: Sun Jul 25, 2004 1:29 am
by lolpix
Tell me if this helps

Code: Select all

switch($_GET&#1111;"action"]) 
&#123; 
    case "add_item": 
    AddItem($_GET&#1111;"id"], $_GET&#1111;"qty"]); 
    ShowCart(); 
    break; 
 
    case "update_item": 
    UpdateItem($_GET&#1111;"id"], $_GET&#1111;"qty"]); 
    ShowCart(); 
    break; 
 
    case "remove_item": 
    RemoveItem($_GET&#1111;"id"]); 
    ShowCart(); 
    break; 
  
    default: 
    ShowCart();
    break;

&#125;
http://us2.php.net/switch

Posted: Sun Jul 25, 2004 1:35 am
by C_Calav
thanx lolpix,

still the same error:

Parse error: parse error, unexpected T_VARIABLE, expecting '{' in /var/users/modelair/modelaircraft.co.nz/htdocs/cart.php on line 31


Code: Select all

<?php 

include("db.php"); 

switch($_GET["action"]) 
{ 
    case "add_item": 
    AddItem($_GET["id"], $_GET["qty"]); 
    ShowCart(); 
    break; 

    case "update_item": 
    UpdateItem($_GET["id"], $_GET["qty"]); 
    ShowCart(); 
    break; 

    case "remove_item": 
    RemoveItem($_GET["id"]); 
    ShowCart(); 
    break; 
  
    default: 
    ShowCart(); 
    break; 

} 


function AddItem($itemId, $qty) 

$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); 
} 
mysql_query("update cart set qty = $qty where cookieId = '" . GetCartId() . "' and itemId = $itemId"); 

function RemoveItem($itemId) 

mysql_query("delete from cart where cookieId = '" . GetCartId() . "' and itemId = $itemId"); 


$result = mysql_query("select * from cart inner join items on cart.itemId = items.itemId where cart.cookieId = '" . GetCartId() . "' order by items.itemName asc");

while($row = mysql_fetch_array($result)) 
{ 
// Increment the total cost of all items 
$totalCost += ($row["qty"] * $row["itemPrice"]); 
?> 
<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["itemName"]; ?> 
</font> 
</td> 
<td width="20%" height="25"> 
<font face="verdana" size="1" color="black"> 
$<?php echo number_format($row["itemPrice"], 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> 
<?php 
} 

// Increment the total cost of all items 
$totalCost += ($row["qty"] * $row["itemPrice"]); 

$totalCost = $totalCost + ($row["qty"] * $row["itemPrice"]); 

<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> 

<script language="JavaScript"> 

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> 

<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="products.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>

Posted: Sun Jul 25, 2004 1:49 am
by lolpix
function RemoveItem($itemId) should be RemoveItem($itemId); ?

Posted: Sun Jul 25, 2004 1:50 am
by lolpix
Maybe I am wrong, but all this is nonsense...

Code: Select all

function RemoveItem($itemId) 

mysql_query("delete from cart where cookieId = '" . GetCartId() . "' and itemId = $itemId"); 


$result = mysql_query("select * from cart inner join items on cart.itemId = items.itemId where cart.cookieId = '" . GetCartId() . "' order by items.itemName asc");

Posted: Sun Jul 25, 2004 1:55 am
by C_Calav
the ; on the end of the remove function still puts out

Parse error: parse error, unexpected T_VARIABLE, expecting '{' in /var/users/modelair/modelaircraft.co.nz/htdocs/cart.php on line 31

it cud be nonsense! im learning how to code a shopping cart. they all say its easy yadda yadda (and im sure it is :roll:) he he

im just trying to understand whats going wrong. if anyone has any ideas?

dont have to follow this script but this script i can follow compared to other cart tutorials

Posted: Sun Jul 25, 2004 2:00 am
by lolpix
Are you sure you are following the toot line for line? With the exception of the $result variable the code I quoted appears to be doing nothing.

Posted: Sun Jul 25, 2004 2:06 am
by C_Calav
the tutorial is a bit itsy bitsy but im pretty sure i got it all. here it is is anyone wants to see:

Building A Persistent Shopping Cart With PHP and MySQL - The cart.php script
( Page 4 of 6 )

A shopping cart must perform four functions. It must allow users to add and remove products from their cart. It must allow them to change the quantity of items for each product in their cart, and it must also allow them to actually see the products in their cart, as well as a cumulative total of all of the products in their cart.

Cart.php contains four functions that implement the work described in the previous paragraph. Cart.php requires on a query string variable, action, to tell it what to do:

Code: Select all

<?php 

include("db.php"); 

switch($_GET["action"]) 
{ 
case "add_item": 
{ 
AddItem($_GET["id"], $_GET["qty"]); 
ShowCart(); 
break; 
} 
case "update_item": 
{ 
UpdateItem($_GET["id"], $_GET["qty"]); 
ShowCart(); 
break; 
} 
case "remove_item": 
{ 
RemoveItem($_GET["id"]); 
ShowCart(); 
break; 
} 
default: 
{ 
ShowCart(); 
} 
} 

As you can see, I'm using the $_GET associative array, which was introduced with PHP version 4.1, and made standard with PHP version 4.2. In PHP 4.2, $HTTP_GET_VARS is deprecated, so you should get into the habit of using $_GET and $_POST instead of $HTTP_GET_VARS and $HTTP_POST_VARS. Using $_GET is quicker too, because it is automatically globally scoped, whereas $HTTP_GET_VARS is not. 

Looking at the switch statement above, we have four possible cases, each of which is discussed below:
add_item: When the user clicks on the "Add Item" for an item on the products.php page, this case will be called. It calls the AddItem function, passing in an items ID and quantity.
update_item: Updates the quantity of an item in the users shopping cart. As you will see shortly, each item in the cart is displayed with a drop down list, that, when changed, automatically updates the numeric of a specific item in the users shopping cart.
remove_item: Deletes an item from the cart table for the current user.
If the cart.php page is called up with no query string parameters, then the ShowCart function is called. Let's start by looking at the AddItem function. 

AddItem accepts two parameters: The ID of the item to add to the cart, and the number of that item to add: 

function AddItem($itemId, $qty) 

The main part of the AddItem function checks whether or not this item already exists in the users cart. If it does, then its quantity field is updated and it isn't added again: 

$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); 
} 

Looking at the code above, we can see that if $numRows equals zero (i.e. the item isn’t already in the users cart) then the item is added to the cart table. If not, the items quantity field is updated by calling the UpdateItem function, which is described below. 

UpdateItem accepts two parameters, in the same way that the AddItem function does: 

function UpdateItem($itemId, $qty) 

It executes a simple UPDATE SQL query against the cart table, updating the quantity of one specific item. The cookieId field is used to match the users session ID to that particular product, making sure that the quantity is only updated for that item and the current user: 

mysql_query("update cart set qty = $qty where cookieId = '" . GetCartId() . "' and itemId = $itemId"); 

Removing an item is a simple matter of the RemoveItem function being called. It accepts just one parameter, which is the ID of the item to delete: 

function RemoveItem($itemId) 

Once connected to the database, a simple SQL DELETE query removes the item from the current users cart: 

mysql_query("delete from cart where cookieId = '" . GetCartId() . "' and itemId = $itemId"); 

All of these functions are good, but to actually call them, we need to look at the ShowCart function, which is what we will do on the next page.

At this point we need a way to list all of the items in our shopping cart, as well as a total cost for all of those items. ShowCart handles all of this. It also provides a drop down list for each item, so that its quantity can be easily updated. 

ShowCart starts off by using an SQL INNER JOIN query to get a list of items from the cart table, and also each items details from the items table: 

$result = mysql_query("select * from cart inner join items on cart.itemId = items.itemId where cart.cookieId = '" . GetCartId() . "' order by items.itemName asc"); 

Once the list of items is retrieved, each item is displayed as part of a table, as a table row: 

while($row = mysql_fetch_array($result)) 
{ 
// Increment the total cost of all items 
$totalCost += ($row["qty"] * $row["itemPrice"]); 
?> 
<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["itemName"]; ?> 
</font> 
</td> 
<td width="20%" height="25"> 
<font face="verdana" size="1" color="black"> 
$<?php echo number_format($row["itemPrice"], 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> 
<?php 
} 

The running tally of each item in the users shopping cart is kept as the $totalCost variable: 

// Increment the total cost of all items 
$totalCost += ($row["qty"] * $row["itemPrice"]); 

The quantity of each item is multiplied by its price, and is then added to the $totalCost variable using the += operator, which is the same as: 

$totalCost = $totalCost + ($row["qty"] * $row["itemPrice"]); 

As I mentioned above, the quantity for each item is displayed in a drop down list. This list is generated with the following code: 

<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> 

The <select> tag contains a trigger for the onChange event, which calls a JavaScript function called UpdateQty. UpdateQty is defined at the top of the ShowCart function, and looks like this: 

<script language="JavaScript"> 

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> 

Once called, UpdateQty takes the quantity of the selected item as well as the items ID (which is the name of the drop down list) and passes them as query string variables to cart.php. For example, if I updated the quantity of a product whose ID was 5 to 4, then I would be redirected to the following URL: 

cart.php?action=update_item&id=5&qty=4 

Lastly, ShowCart displays the total cost of all items in the users cart: 

<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="products.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>
[

Posted: Sun Jul 25, 2004 2:36 am
by sanyuan
Don't you need to open a bracket after declaring a function :

(this is what you have )
function AddItem($itemId, $qty)

$result



(this is what you should have)
function AddItem($itemId, $qty)
{
$result

Posted: Sun Jul 25, 2004 6:57 am
by C_Calav
thanx sanyuan for your advice.

ive re-looked the code and made some mistakes. ive cleaned it up best i can but now getting caught out here.
i see why but dont see why 8O

heres the error:

Parse error: parse error, unexpected '<' in /var/users/modelair/modelaircraft.co.nz/htdocs/cart.php on line 111

Code: Select all

<?php 

include("db.php"); 

switch($_GET["action"]) 
{ 
    case "add_item": 
    AddItem($_GET["id"], $_GET["qty"]); 
    ShowCart(); 
    break; 

    case "update_item": 
    UpdateItem($_GET["id"], $_GET["qty"]); 
    ShowCart(); 
    break; 

    case "remove_item": 
    RemoveItem($_GET["id"]); 
    ShowCart(); 
    break; 
  
    default: 
    ShowCart(); 
    break; 

} 


function AddItem($itemId, $qty) 
{
$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)
{
mysql_query("update cart set qty = $qty where cookieId = '" . GetCartId() . "' and itemId = $itemId"); 
}

function RemoveItem($itemId)
{
mysql_query("delete from cart where cookieId = '" . GetCartId() . "' and itemId = $itemId"); 
}



//show cart
$result = mysql_query("select * from cart inner join items on cart.itemId = items.itemId where cart.cookieId = '" . GetCartId() . "' order by items.itemName asc");

while($row = mysql_fetch_array($result)) 
{ 
// Increment the total cost of all items 
$totalCost += ($row["qty"] * $row["itemPrice"]); 
?> 
<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["itemName"]; ?> 
</font> 
</td> 
<td width="20%" height="25"> 
<font face="verdana" size="1" color="black"> 
$<?php echo number_format($row["itemPrice"], 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> 
<?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="products.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>

Posted: Sun Jul 25, 2004 7:04 am
by C_Calav
thanx sanyuan for your advice.

ive re-looked the code and made some mistakes. ive cleaned it up best i can but now getting caught out here.
i see why but dont see why 8O

heres the error:

Parse error: parse error, unexpected '<' in /var/users/modelair/modelaircraft.co.nz/htdocs/cart.php on line 111

Code: Select all

<?php 

include("db.php"); 

switch($_GET["action"]) 
{ 
    case "add_item": 
    AddItem($_GET["id"], $_GET["qty"]); 
    ShowCart(); 
    break; 

    case "update_item": 
    UpdateItem($_GET["id"], $_GET["qty"]); 
    ShowCart(); 
    break; 

    case "remove_item": 
    RemoveItem($_GET["id"]); 
    ShowCart(); 
    break; 
  
    default: 
    ShowCart(); 
    break; 

} 


function AddItem($itemId, $qty) 
{
$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)
{
mysql_query("update cart set qty = $qty where cookieId = '" . GetCartId() . "' and itemId = $itemId"); 
}

function RemoveItem($itemId)
{
mysql_query("delete from cart where cookieId = '" . GetCartId() . "' and itemId = $itemId"); 
}



//show cart
$result = mysql_query("select * from cart inner join items on cart.itemId = items.itemId where cart.cookieId = '" . GetCartId() . "' order by items.itemName asc");

while($row = mysql_fetch_array($result)) 
{ 
// Increment the total cost of all items 
$totalCost += ($row["qty"] * $row["itemPrice"]); 
?> 
<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["itemName"]; ?> 
</font> 
</td> 
<td width="20%" height="25"> 
<font face="verdana" size="1" color="black"> 
$<?php echo number_format($row["itemPrice"], 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> 
<?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="products.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>

Posted: Sun Jul 25, 2004 10:51 am
by zenabi
Near the end of your code you did not end the php tag:

Code: Select all

<a href="cart.php?action=remove_item&id=<?php echo $row["itemId"]; ?>">Remove</a> 
</font> 
</td> 
</tr> 
<?php 
} 
/* Add ?> here */

<tr> 
<td width="100%" colspan="4"> 
<hr size="1" color="red" NOSHADE> 
</td> 
</tr>