Jump to content
Sign in to follow this  


Recommended Posts

$dbConn = new mysqli("localhost", "student", "Autumn", "fact");
if($dbConn->connect_error) {
die("Failed to connect to database " . $dbConn->connect_error);




$number = $_POST["quantity"];

 if (isset($_POST["submit"])) { 
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> ";
           echo "<p class='errorMsg'>input can not be blank</p> ";

<!DOCTYPE html>
<html lang="en">
    <meta charset="utf-8">
      input[type="text"] {border: 1px solid black;}
    <link rel="stylesheet" href="styles.css">
      <form id="" action="" method="post"> 
<h1>Product In Stock </h1>
while ($row = $results->fetch_assoc()) { ?>
<td><?php echo $row["name"]?></td>
<td><?php echo $row["quantityInStock"]?></td>
<td><?php echo $row["price"]?></td>

<?php }  

$dbConn->close(); ?>

Share this post

Link to post
Share on other sites

Is there a question here?

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this