mindapolis Posted November 27, 2011 Share Posted November 27, 2011 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> Quote Link to comment https://forums.phpfreaks.com/topic/251869-function-trouble/ Share on other sites More sharing options...
MasterACE14 Posted November 27, 2011 Share Posted November 27, 2011 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' Quote Link to comment https://forums.phpfreaks.com/topic/251869-function-trouble/#findComment-1291483 Share on other sites More sharing options...
mindapolis Posted November 27, 2011 Author Share Posted November 27, 2011 I fixed that problem but it didn't fix the main problem. am I passing $price right to the function? Quote Link to comment https://forums.phpfreaks.com/topic/251869-function-trouble/#findComment-1291620 Share on other sites More sharing options...
MasterACE14 Posted November 28, 2011 Share Posted November 28, 2011 You don't appear to be calling your function at all. Quote Link to comment https://forums.phpfreaks.com/topic/251869-function-trouble/#findComment-1291749 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.