$query1 = "SELECT `id`,`type` FROM `items_type`"; $sth1 = $dbh->query($query1); while ($item_type = $sth1->fetch(PDO::FETCH_ASSOC)) { $item_id = $item_type['id']; echo '<h4>' . ucfirst($item_type['type']) . ': </h4><hr>'; if ($admin_location == 273) { $query2 = "SELECT `id`,`name`,`description`,`price`,`pic`,`location`,`admin_id`,`date` FROM `items` WHERE `type` = {$item_id}"; } else { $query2 = "SELECT `id`,`name`,`description`,`price`,`pic`,`location`,`admin_id`,`date` FROM `items` WHERE `type` = {$item_id} AND `location` = '{$admin_location}'"; } $sth2 = $dbh->query($query2); if ($sth2->rowCount() == 0) { echo '<p>No Products to Display in this Category.</p>'; } while ($result2 = $sth2->fetch(PDO::FETCH_ASSOC)) { display_product($result2); } echo '<span class = "clearfix"></span>'; } } ?> </div> </div> <!Modal for Delete> <div id="deleteConfirmation" class="modal fade"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title">Confirmation</h4>
} if (isset($_SESSION['search_key']) && !empty($_SESSION['search_key'])) { $location = $_SESSION['location']; $search = '%' . $_SESSION['search_key'] . '%'; $query1 = "SELECT `id`,`name`,`price`,`pic` FROM `items` WHERE `location` = '{$location}' AND `name` LIKE :search_key OR `description` LIKE :search_key"; $sth1 = $dbh->prepare($query1); $sth1->bindParam(':search_key', $search, PDO::PARAM_STR); $sth1->execute(); if ($sth1->rowCount() == 0) { echo '<h4>Sorry! This Product type is not avaliable in Your area. Kindly contact Customer Support for further assistance.</h4>'; } else { while ($result1 = $sth1->fetch(PDO::FETCH_ASSOC)) { display_product($result1); } } unset($_SESSION['search_key']); } else { if (isset($_REQUEST['id']) && !empty($_REQUEST['id']) && isset($_SESSION['location'])) { $id_type = substr($_REQUEST['id'], 5); $location = $_SESSION['location']; $query1 = "SELECT `id`,`name`,`price`,`pic` FROM `items` WHERE `type` = '{$id_type}' AND `location` = '{$location}'"; $sth1 = $dbh->query($query1); if ($sth1->rowCount() == 0) { echo '<h4>Sorry! This Product type is not avaliable in Your area. Kindly contact Customer Support for further assistance.</h4>'; } else { while ($result1 = $sth1->fetch(PDO::FETCH_ASSOC)) { display_product($result1); } } } }
if (isset($_POST['id'])) { $res = change_db($link); } else { $res = change_db($link, true); } header("Locetion: " . $_SERVER['REQUEST_URI']); } $items = get_item($link); ?> <a href="/work_23_03/logout.php" class="pull-right btn btn-danger">Logout <?php echo $_SESSION['login']; ?> </a> <div class="clearfix"></div> <?php if ($_SESSION['admin'] == 'y') { display_form(); } echo "<div class='clearfix'></div>"; foreach ($items as $item) { if ($_SESSION['admin'] == 'y') { display_form(true, $item); } elseif ($item['is_active']) { display_product($item); } } ?> </div> </div> </body> </html>