<?php
$dbConn = new mysqli("localhost", "student", "Autumn", "fact");
if($dbConn->connect_error) {
die("Failed to connect to database " . $dbConn->connect_error);
}
?>
<?php
error_reporting(E_PARSE);
//require_once("conn.php");
$number = $_POST["quantity"];
if (isset($_POST["submit"])) {
if(!empty($number)){
if (is_numeric($number)){
if($number < 60){
$sql = "SELECT name, quantityInStock, price FROM product where quantityInStock > $number order by quantityInStock ASC ";
$results = $dbConn->query($sql)
or die ('Problem with query: ' . $dbConn->error);
}
else { echo "<p class='errorMsg'>There are no products that have more than 60 in stock.</p>";
}
}
else {
echo "<p class='errorMsg'> The value entered for quantity was not a number. </p> ";
}
}
else
{
echo "<p class='errorMsg'>input can not be blank</p> ";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style>
input[type="text"] {border: 1px solid black;}
</style>
<link rel="stylesheet" href="styles.css">
<title>Quiz</title>
</head>
<body>
<form id="" action="" method="post">
<h1>Product In Stock </h1>
<table>
<tr>
<th>Name</th>
<th>QuantityInStock</th>
<th>Price</th>
</tr>
<?php
while ($row = $results->fetch_assoc()) { ?>
<tr>
<td><?php echo $row["name"]?></td>
<td><?php echo $row["quantityInStock"]?></td>
<td><?php echo $row["price"]?></td>
</tr>
<?php }
$dbConn->close(); ?>
</table>
</form>
</body>
</html>