database
I realize that this is an old post, but you put the wrong database in the zip file
<?php if(!$conn){ } ?>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1"/> <link rel="stylesheet" type="text/css" href="css/bootstrap.css" /> </head> <body> <nav class="navbar navbar-default"> <div class="container-fluid"> <a class="navbar-brand" href="https://sourcecodester.com">Sourcecodester</a> </div> </nav> <div class="col-md-3"></div> <div class="col-md-6 well"> <h3 class="text-primary">PHP - Search Data Between Two Dates</h3> <hr style="border-top:1px dotted #ccc;"/> <button class="btn btn-success" type="button" data-toggle="modal" data-target="#form_modal"><span class="glyphicon glyphicon-plus"></span> Add product</button> <br /><br /> <form method="POST" action=""> <div class="form-inline"> <input type="date" class="form-control" name="from" required="required"/> <input type="date" class="form-control" name="to" required="required"/> <button class="btn btn-primary" name="search"><span class="glyphicon glyphicon-search"></span> Search</button> </div> </form> <br /> <table class="table table-bordered"> <thead class="alert-info"> <tr> <th>Product name</th> <th>Brand</th> <th>Price</th> <th>Date Receive</th> </tr> </thead> <tbody><?php include 'search.php'?></tbody> </table> </div> <div class="modal fade" id="form_modal" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <form method="POST" action="save.php"> <div class="modal-header"> <h3 class="modal-title">Add Product</h3> </div> <div class="modal-body"> <div class="col-md-2"></div> <div class="col-md-8"> <div class="form-group"> <label>Product name</label> <input type="text" class="form-control" name="product_name" required="required"/> </div> <div class="form-group"> <label>Brand</label> <input type="text" class="form-control" name="brand" required="required"/> </div> <div class="form-group"> <label>Price</label> <input type="number" min="0" class="form-control" name="price" required="required"/> </div> <div class="form-group"> <label>Date Receive</label> <input type="date" class="form-control" name="date_receive" required="required"/> </div> </div> </div> <br style="clear:both;"/> <div class="modal-footer"> <button type="button" class="btn btn-danger" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span> Close</button> <button class="btn btn-primary" name="save"><span class="glyphicon glyphicon-save"></span> Save</button> </div> </form> </div> </div> </div> <script src="js/jquery-3.2.1.min.js"></script> <script src="js/bootstrap.js"></script> </body> </html>
<?php require_once 'conn.php'; $product_name = $_POST['product_name']; $brand = $_POST['brand']; $price = $_POST['price']; $date = $_POST['date_receive']; mysqli_query($conn, "INSERT INTO `product` VALUES('', '$product_name', '$brand', '$price', '$date')") or die(mysqli_error()); } ?>
<?php require 'conn.php'; $from = $_POST['from']; $to = $_POST['to']; $query = mysqli_query($conn, "SELECT * FROM `product` WHERE date_receive BETWEEN '$from' AND '$to'") or die(mysqli_error()); echo "<tr> <td>".$fetch['product_name']."</td> <td>".$fetch['brand']."</td> <td>".$fetch['price']."</td> <td>".$fetch['date_receive']."</td> </tr>"; } }else{ echo "<tr> <td>".$fetch['product_name']."</td> <td>".$fetch['brand']."</td> <td>".$fetch['price']."</td> <td>".$fetch['date_receive']."</td> </tr>"; } } ?>