} else { echo "No items were found."; } // clean duplicates $results_arr = array_unique($results_arr); // loop the results array and display results foreach ($results_arr as $result_id) { showDB($result_id, $display); } // end foreach // NORMAL SEARCH } elseif (isset($_GET['q']) && !empty($_GET['q'])) { $query = filter_var($_GET['q'], FILTER_SANITIZE_STRING); // we make an array for the resulting ids $results_arr = array(); $results_arr = search_item('db', $query, $_SESSION['userid']); // filter out duplicate ids and reverse the order; items should be sorted by date $results_arr = array_reverse(array_unique($results_arr)); // show number of results found if (count($results_arr) > 1) { echo "Found " . count($results_arr) . " results."; } elseif (count($results_arr) == 1) { echo "Found 1 result."; } else { echo "Nothing found :("; } // loop the results array and display results foreach ($results_arr as $result_id) { showDB($result_id, $display); } // end if there is a search
<tr> <td> </td> <td> <input type="submit" name='search' value="Search"/> <input type="submit" name='report_found' value="Report Found"/> </td> </tr> </table> </form> <table id='resultsTable'> <?php if (isset($_POST['search'])) { $array = search_item($dbc, $_POST); foreach ($array as $item) { echo '<tr><td>' . $item['item'] . '</td>'; echo '<td>' . $item['location_id'] . '</td>'; echo '<td>' . $item['room'] . '</td>'; echo '<td>' . $item['description'] . '</td></tr>'; } } mysqli_close($dbc); ?> </table> </div>
<?php # If the user submitted a search action, generate the search table here if (isset($_POST['search'])) { $identifier = $_POST['search']; echo "<table id='resultsTable'>"; echo '<tr><th>Item</th>'; echo '<th>' . ucwords($person) . '</th>'; echo '<th>Phone</th>'; echo '<th>Email</th>'; # Location name listed under 'name' in the query echo '<th>Building</th>'; echo '<th>Room</th>'; echo '<th>Description</th></tr>'; # Search the database with the specified fields $array = search_item($dbc, $_POST, $page_status); foreach ($array as $item) { echo '<tr><td><a href=item.php?id=' . $item['item_id'] . '>' . $item['item'] . '</a></td>'; # Location name listed under 'name' in the query echo '<td>' . $item[$person] . '</td>'; echo '<td>' . $item['phone'] . '</td>'; echo '<td>' . $item['email'] . '</td>'; echo '<td>' . $item['name'] . '</td>'; echo '<td>' . $item['room'] . '</td>'; echo '<td>' . $item['description'] . '</td></tr>'; } echo "</table>"; } elseif (isset($_POST['report'])) { echo "<div style='margin-left:5em'>"; foreach ($errors as $e) { echo $e;
$gerger->start(); $gerger->setprecision(4); session_start(); if (isset($_POST['searchstr'])) { $keywords = $_POST['searchstr']; $_SESSION['search_string'] = $keywords; } if (isset($_SESSION['search_string'])) { $keywords = $_SESSION['search_string']; } // Perform the search $results = search_keyword($keywords); //search for articles on the keywords table $ids = combine_ids($results); //combine all found article ids into one array $rs = search_item($ids); //search actuall articles $searchresults = ''; $totalrows = count($rs); $limit = 2; $paging = ceil($totalrows / $limit); $scroll = 1; $scrollnumber = 5; if (isset($_GET['page'])) { $page = $_GET['page']; } else { $page = 1; } $start = $page * $limit - $limit; $pagelink = new paging($page, $totalrows, $limit, $paging, $scroll, $scrollnumber); //print_r($pagelink);