Link to code Since you cannot divide by 0, my php is to display an error message but, although it displays the error message it also displays the table that should appear if not dividing by 0. How can I prevent that?
<!DOCTYPE html>
<html>
<head>
<title>Math Calculations!</title>
</head>
<body>
<!-- Background color selection for site-->
<body style="background-color:#ACDDE3;">
<?php
My values
// input values
$firstInt = $_POST["firstInt"];
$secondInt = $_POST["secondInt"];
$calc = $_POST["calc"];
$result = 0;
// inc-math-problems.php
include ("juarez-inc-calc.php");
The statements
elseif ($calc == "Multiplication") {
$calculation = "Multiplication";
$prefix = "The product of";
$result = prodIntegers($firstInt, $secondInt);
}
elseif ($calc == "Divison") {
$calculation = "Divison";
$prefix = "The quotient of";
Target
if ($secondInt == 0){
print("Error: You can't divide by zero
$result = "invalid";
}
else{
$result = quotIntegers($firstInt, $secondInt);
}
The print statements
print("<style>
table, th, td {
border: 1px solid black;
padding: 5px;
}
table {
border-spacing: 5px;
}
</style>
</head>
<body>
<h2>The Results</h2>
<table>
<tr>
<th>Operation</th>
<th>Result</th>
</tr>
<tr>
<td>$calculation</td>
<td>$result</td>
</tr>
</table>");
print("<a href=\"juarez-calculations.html\"> Return to form </a>");
?>
</body>
</html>