Jump to content

function trouble


mindapolis

Recommended Posts

I wrote a simple sales tax function but it keeps come back with a sales tax of 0 the price is coming from a database. 

 


function TotalSalesTax($price)
{
	$salesTax = .07;
	$TotalSalesTax = $price * $salesTax;
    number_format($TotalSalesTax, 2);	
	return $TotalSalesTax;		
}

 

<tr>  
    <td></td>  
    <td>Sales Tax:  </td>
    <td><?php echo TotalSalesTax($price);?>  	</td> 
</tr>

 

product page that the price comes from

<?php
session_start();
if(!isset($_SESSION['quantity']))

{
  $_SESSION['quanity']=array(); //if there are no quantities selected, the array is empty
  if(is_array($_POST['quantity']))//if there are items in the cart
{
  echo $quantity;
  header("location: checkOut.php");
}
}
require_once("functions.php");
?>  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
td {
border-top-style: solid; 
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #30C;
border-right-color: #30C;
border-bottom-color: #30C;
border-left-color: #30C;
}
#productCatalog {
width:400px;   
margin-right: auto;
margin-left: auto;
}
</style>
<link href="doggyTreats.css" rel="stylesheet" type="text/css" />
</head>

<body>
<?php
logo();
navBar();
echo "<div id=\"productCatalog\">";
echo "<form action=\"checkOut.php\" method=\"post\" name=\"catalog\">";
  
DatabaseConnection();  

  $query = "SELECT * FROM treats"; 
        $result_set = mysql_query($query) or die(mysql_error());
$i = 0;

        echo "<table>";
        while ($row = mysql_fetch_array($result_set))
        {
	echo"<tr><td width=\"2s00px\"><img src=\"{$row['product_pic']}\" /></td><td width=\"200px\">{$row['product_title']}.<br /><br />{$row['product_Description']}.<br /> Price:  \${$row['price']}.<br /><br />Quantity <input name=\"quantity\" type=\"text\" size=\"2\" /></td></tr>";
        }
		echo "<tr>"; 
		echo "<td><input name=\"submit\" type=\"submit\" value=\"Proceed to Checkout\" />"; 
	echo "</table>";    
	echo "</form>";
echo "</div>";
footer();
?>
</body>
</html>

Link to comment
Share on other sites

I'll be honest, I haven't read the entire script. But you do have a typo near the start which is probably the issue:

$_SESSION['quanity']=array(); //if there are no quantities selected, the array is empty

should be

$_SESSION['quantity']=array(); //if there are no quantities selected, the array is empty

missing the first 't' in 'quantity'

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.