Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Select all as the alias 'inv' from the 'stones' table
- Count all rows and store the number for rows in the variable 'totalRows'
- as long as the 'wt' column is greater than or equal to 2.5
- */
- $SQL = "SELECT inv.*, COUNT(*) OVER() AS totalrows FROM stones inv WHERE wt >= 2.5";
- if (isset($_POST["ItemSearch"])) $SQL .= "AND number LIKE '" . $_POST["ItemSearch"] . "%'";
- if (isset($_POST["minimum_wt"], $_POST["maximum_wt"]) && !empty($_POST["minimum_wt"]) && !empty($_POST["maximum_wt"])) $SQL .= "AND wt BETWEEN '" . $_POST["minimum_wt"] . "' AND '" . $_POST["maximum_wt"] . "'";
- if (isset($_POST["shape"])) {
- $ShapeFilter_SharpCorners = ["EC", "AS", "RA", "PR"]; // Emerald cut, Asscher, Radiant, Princess cut
- $ShapeFilter = implode("','", $_POST["shape"]);
- $SQL .= "AND stoneshape IN('" . $ShapeFilter . "')";
- }
- if (isset($_POST["color"])) {
- $ColorFilter = implode("','", $_POST["color"]);
- $SQL .= "AND stonecolor IN('" . $ColorFilter . "')";
- }
- if (isset($_POST["enhancement"])) {
- $EnhancementFilter = implode("','", $_POST["enhancement"]);
- $SQL .= "AND enhcode IN('" . $EnhancementFilter . "')";
- }
- if (isset($_POST["matching"])) {
- $MatchingFilter = implode("','", $_POST["matching"]);
- $SQL .= "AND pair IN('" . $MatchingFilter . "')";
- }
- $PageNo = $_REQUEST['PageNo']; // Get page number (paginate)
- $Limit = 25; // Items per page
- $Offset = ($PageNo - 1) * $Limit; // Current page times the amount per page
- $SQL .= "AND inactive LIKE 0 ORDER BY wt ASC LIMIT $Offset, $Limit;"; // $Offset and $Limit are declared in their respective variables
- $MySQLiQuery = mysqli_query($db, $SQL); // Preform the query against the database
- ?>
Add Comment
Please, Sign In to add comment