Hey Guys, sorry for the vague info earlier, I was in too much of a rush to post. I haven't begun to make the if statement yet, but I was going to put another php section for it right before the html begins.
I didn't create any of this code, it came with the package we bought. Here's the entire page, view_cart.php:
<?
session_start();
include_once('FX/server_data.php');
include_once('FX/FX.php');
include_once('FX/FMErrors.php');
if(empty($_SESSION['ordno'])){
include_once('index.php');
}else{
$style=new FX($serverIP,$webCompanionPort);
$style->SetDBData('FXCart.fp7','Web_Setup');
$style->SetDBPassword('blah','blah');
$styleResult=$style->FMFindAll();
foreach($styleResult['data']as $key=>$styleData);
$cats=new FX($serverIP,$webCompanionPort);
$cats->SetDBData('FXCart.fp7','Categories');
$cats->SetDBPassword('blah','blah');
$catsResult=$cats->FMFindAll();
$order=new FX($serverIP,$webCompanionPort);
$order->SetDBData('FXCart.fp7','Orders_Temp');
$order->SetDBPassword('blah','blah');
$order->AddDBParam('Order_No',$_SESSION['ordno']);
$orderResult=$order->FMFind();
foreach($orderResult['data']as $key=>$orderData);
//update shopping cart begin
if(isset($_POST['type'])){
if($_POST['type']=='updatecart'){
$reccom=$_POST['reccom'];
for($i=0; $i<count($reccom); $i++){
$qty[$i]=$_POST['qty'.$i];
$remove[$i]=$_POST['remove'.$i];
$update=new FX($serverIP,$webCompanionPort);
$update->SetDBData('FXCart.fp7','LineItems');
$update->SetDBPassword('blah','blah');
$update->AddDBParam('-recid',$reccom[$i]);
$update->AddDBParam('qty',$qty[$i]);
if($remove[$i]=='Yes'){
$updateResult=$update->FMDelete();
}else{
$updateResult=$update->FMEdit();
}
}
} }
//update shopping cart end
$items=new FX($serverIP,$webCompanionPort);
$items->SetDBData('FXCart.fp7','LineItems');
$items->SetDBPassword('blah','blah');
$items->AddDBParam('Order_No',$_SESSION['ordno']);
$itemsResult=$items->FMFind();
if(isset($_SESSION['ordno'])){
$totals=new FX($serverIP,$webCompanionPort);
$totals->SetDBData('FXCart.fp7','Orders_Temp');
$totals->SetDBPassword('blah','blah');
$totals->AddDBParam('Order_No',$_SESSION['ordno']);
$totalsResult=$totals->FMFind();
foreach($totalsResult['data']as $key=>$totalsData);
$items=$totalsData['Items'][0];
$subtotal=$totalsData['Order_Subtotal'][0];
$tax=$totalsData['Tax'][0];
$total=$totalsData['Order_Total'][0];
$shipping=$totalsData['Shipping'][0];
}else{
$items='0';
$total='0.00';
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>FXCart FMWebschool.com</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="webstyle.css" rel="stylesheet" type="text/css">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<? include_once('includes/header.php'); ?>
<p> </p>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="200" valign="top"><? include_once('includes/left.php'); ?></td>
<td align="center" valign="top" class="arial10B"><p> </p>
<form method="post" action="view_cart.php">
<input type="hidden" name="type" value="updatecart">
<table width="96%" border="1" cellpadding="1" cellspacing="0" bordercolor="<? echo $styleData['cart_border'][0]; ?>">
<?
$int=0;$ant=0;
foreach($itemsResult['data']as $key=>$itemsData){
$int++;
?>
<input type="hidden" name="reccom[]" value="<? echo $itemsData['Line_ID'][0]; ?>">
<tr class="arial10">
<td align="center"><input name="qty<? echo $ant; ?>" type="text" value="<? echo $itemsData['Qty'][0]; ?>" size="4">
</td>
<td><? echo $itemsData['Products::Item_Name'][0]; ?></td>
<td><? echo $itemsData['Products::Item_Description'][0]; ?></td>
<td align="right">$<? echo $itemsData['Item_Total'][0]; ?></td>
<td valign="middle"><input type="checkbox" name="remove<? echo $ant; ?>" value="Yes">
Remove</td>
</tr>
<?
$ant++;
}
?>
<tr class="arial10">
<td colspan="3" align="right"><span class="arial10B">Subtotal</span> </td>
<td align="right">$<? echo $subtotal; ?> </td>
<td valign="middle"> </td>
</tr>
<tr class="arial10">
<td colspan="3" align="right"><span class="arial10B">Tax</span> </td>
<td align="right">$<? echo $tax; ?> </td>
<td valign="middle"> </td>
</tr>
<tr class="arial10">
<td colspan="3" align="right"><span class="arial10B">Shipping</span> </td>
<td align="right">$<? echo $shipping; ?> </td>
<td valign="middle"> </td>
</tr>
<tr class="arial10">
<td colspan="3" align="right"><span class="arial10B">Total</span> </td>
<td align="right">$<? echo $total; ?> </td>
<td valign="middle"><input type="image" name="submit" src="images/update.jpg" width="82" height="17"></td>
</tr>
</table> <br>
</form>
<form method="post" action="http://data.honoluluacademy.org/php_paypal/process.php">
<input type="hidden" name="invoice" value="<? echo $_SESSION['ordno']; ?>">
<input type="hidden" name="item_name" value="Order# <? echo $_SESSION['ordno']; ?>">
<input type="hidden" name="amount" value="<? echo $orderData['Order_Total'][0]; ?>">
<table width="400" border="0" cellspacing="0" cellpadding="1">
<tr>
<td align="right"><a href="index.php"><img src="images/continue_shopping.jpg" width="118" height="17" border="0"></a></td>
<td><input type="image" name="submit" src="images/complete.jpg"></td>
</tr>
</table>
</form></td>
</tr>
</table>
</p>
</body>
</html>
<? } ?>
I also haven't declared my variable for zip code yet, but I'm guessing I'll have to put a line like this underneath the shipping declaration in order to get my if statement to work correctly:
$zip=$totalsData['ZipCode'][0];
Just for some background info... I'm a complete php newbie, but I'm fairly good with FileMaker Pro. I've gone through some basic php training files, but nothing advanced yet. My higher-ups have been hounding me about getting this thing on the road so I'm feeling the pressure. If you want to check out the live site it is at http://data.honoluluacademy.org
The site is basically a purchased, pre-made FileMaker Pro 7 database that included php files. The database, however, had nothing included to calculate shipping costs. I made some scripts within the database to calculate the costs, but in order for them to work, a zip code must be entered. I'm trying to find the best way to get a user to insert the zip code, so I figured the best time is when they want to view their cart (view_cart.php).
I'd like to make it so that if there is no zip code, it redirects to a zip_code.php page. Once the zip code is submitted, it takes you back to view_cart.php