I'm passing cookies from one page to another. Then I'm taking the value of a drop down menu (for quantity) the Price (a cookie) and doing the math to get the total. My submit buttons will calculate and print the total into a <td>.
My issue is when I have two items once I click submit it will remove the value of the one and calculate and print the other.
Any help would be greatly appreciated!
global $tax;
$tax = .06;
if (isset($_COOKIE['shoe1'])) {
print "<tr><td>";
print "<img src=\"Images/1.jpg\" width=\"100px\" height=\"75px\">";
print "</td><td>";
echo $_COOKIE['shoe1']['Description'];
print "</td><td>";
echo $_COOKIE['shoe1']['Item#'];
print "</td><td>";
echo "$" . $_COOKIE['shoe1']['Price'];
print "</td><td>
<form action=\"cart.php\" method=\"POST\">
<select name=\"dropdown1\" id=\"dropdown1\">
<option value=\"1\">1</option>
<option value=\"2\">2</option>
<option value=\"3\">3</option>
<option value=\"4\">4</option>
</select>";
print "<input type=\"submit\" name=\"Calculate\" value=\"Calculate\">
</form></td>
<td style=\"align:center;\" width=\"100px\">";
$amount = $_POST['dropdown1'];
$price = $_COOKIE['shoe1']['Price'];
$total = $price * $amount + $tax;
//
echo $total;
print "</td></tr>";
}
if (isset($_COOKIE['shoe2'])) {
print "<tr><td>";
print "<img src=\"Images/2.jpg\" width=\"100px\" height=\"75px\">";
print "</td><td>";
echo $_COOKIE['shoe2']['Description'];
print "</td><td>";
echo $_COOKIE['shoe2']['Item#'];
print "</td><td>";
echo "$" . $_COOKIE['shoe2']['Price'];
print "</td><td>
<form action=\"cart.php\" method=\"POST\">
<select name=\"dropdown2\" id=\"dropdown2\">
<option value=\"1\">1</option>
<option value=\"2\">2</option>
<option value=\"3\">3</option>
<option value=\"4\">4</option>
</select>";
print "<input type=\"submit\" name=\"Calculate\" value=\"Calculate\">
</form></td>
<td style=\"align:center;\" width=\"100px\">";
$amount = $_POST['dropdown2'];
$price = $_COOKIE['shoe2']['Price'];
$total = $price * $amount + $tax;
echo $total;
print "</td></tr>";
}