Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST['pageno']) || isset($_POST['ItemSearch'])){
- //Include database configuration file
- include('../dbConfig.php');
- $limit = 10;
- $pageno = $_POST['pageno'];
- $offset = !empty($pageno) ? $pageno * $limit : 0;
- //set conditions for search
- $whereSQL = $orderSQL = '';
- $ItemSearch = $_POST['ItemSearch'];
- if(empty($ItemSearch)){
- require('FilterData.php');
- } else {
- $whereSQL = "WHERE wt >= 2.5 AND number LIKE '%".$ItemSearch."%' ";
- $orderSQL = "ORDER BY wt ASC";
- }
- //get number of rows
- $queryNum = $db->query("SELECT COUNT(*) as number FROM stones ".$whereSQL.$orderSQL);
- $resultNum = $queryNum->fetch_assoc();
- $rowCount = $resultNum['number'];
- //initialize pagination class
- $pagConfig = array(
- 'currentPage' => $offset,
- 'totalRows' => $rowCount,
- 'perPage' => $limit,
- 'link_func' => 'searchFilter'
- );
- //get rows
- $SQL = $db->query("
- SELECT
- number,
- image1,
- wt,
- TRUNCATE(length,1) as length,
- TRUNCATE(width,1) as width,
- CASE
- WHEN stonetype = 'SA' THEN 'Sapphire'
- WHEN stonetype = 'RU' THEN 'Ruby'
- WHEN stonetype = 'TML-P' THEN 'Paraiba'
- WHEN stonetype = 'EM' THEN 'Emerald'
- WHEN stonetype = 'TS' THEN 'Tsavorite'
- WHEN stonetype = 'SI' THEN 'Spinel'
- WHEN stonetype = 'GT' THEN 'Garnet'
- WHEN stonetype = 'BER' THEN 'Beryl'
- WHEN stonetype = 'TML' THEN 'Tourmaline'
- WHEN stonetype = 'KO' THEN 'Kornerupine'
- ELSE 'n/a'
- END AS 'stonetype',
- CASE
- WHEN enhcode = 'H' THEN 'Heated'
- WHEN enhcode = 'N' THEN 'Unheated'
- ELSE 'n/a'
- END AS 'enhcode'
- FROM stones
- $whereSQL
- $orderSQL
- LIMIT
- $offset,
- $limit
- ");
- if($SQL->num_rows >= 1){
- while($row = $SQL->fetch_assoc()){
- $postID = $row['number'];
- echo '
- <div class="Stone">
- <!-- landing page -->
- <a href="#ItemPage" class="ItemLink" rel="modal:open" id="' . $row['number']. '">
- <!-- image -->
- <div class="StoneData StoneIMG"> <img src="../../' . $row['image1']. '"> </div>
- <!-- weight -->
- <div class="StoneData">' . $row['wt']. 'Ct</div>
- <!-- type -->
- <div class="StoneData">' . $row['stonetype']. '</div>
- <!-- enhancement -->
- <div class="StoneData">' . $row['enhcode']. '</div>
- <!-- dimensions -->
- <div class="StoneData">' . $row['length']. ' x ' . $row['width']. '</div>
- <!-- item number -->
- <div class="StoneData" id="Number"># ' . $row['number']. '</div>
- </a>
- </div>
- ';
- }
- } else {
- echo '
- <h1 class="Error">
- <span class="mdi mdi-magnify-close mdi-48px"></span>
- NO STONES MATCH THAT
- </h1>
- ';
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement