今、私が得ているのは、私が入れたものと同じ値だけです。したがって、最初のifステートメントを読み取るだけで、それが同じ価格を出力します。
$mysqli = new mysqli("localhost", "root", "", "insuredcars");
if ($_POST['formcar'] == '1' || $_POST['formage'] == '18' || $_POST['formNCD'] == '0' || $_POST['formPoints'] == '0' )
{
$query = $mysqli->query("SELECT * FROM insurance WHERE insuranceid = '3'");
while($row = mysqli_fetch_assoc($query))
{
echo "<tr>";
echo "<td> The price for insurance will be " . $row['insuranceprice'] . "</td>";
echo "</tr>";
}
echo "</table>";
}
else if ($_POST['formcar'] == '6' || $_POST['formage'] == '18' || $_POST['formNCD'] == '0' || $_POST['formPoints'] == '0' )
{
$query = $mysqli->query("SELECT * FROM insurance WHERE insuranceid = '2'");
echo "<tr>";
echo "<td> The price for insurance will be " . $row['insuranceprice'] . "</td>";
echo "</tr>";
echo "</table>";
}
else if ($_POST['formcar'] == '1' || $_POST['formage'] == '19' || $_POST['formNCD'] == '0' || $_POST['formPoints'] == '0' )
{
$query = $mysqli->query("SELECT * FROM insurance WHERE insuranceid = '5'");
echo "<tr>";
echo "<td> The price for insurance will be " . $row['insuranceprice'] . "</td>";
echo "</tr>";
}
echo "</table>";