$success = false; $error_message = $exc->getMessage(); } $FAQs = searchFAQs($searchQuery, $sort_type, $order); } else { //Process GET requests or no requests $page = filter_input(INPUT_GET, "pg"); if (isset($page)) { //if switching page, repeat search $searchQuery = filter_input(INPUT_GET, "q"); $sort_type = filter_input(INPUT_GET, "s"); $order = filter_input(INPUT_GET, "o"); $FAQs = searchFAQs($searchQuery, $sort_type, $order); } else { $page = 1; $FAQs = getFAQs($sort_type, $order); } } ?> <!-- Copyright 2015 NACOSS UNN Developers Group (NDG). Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,
<?php $data = array(); $faqs = getFAQs($data); $title = $lang['head_faq']; ?> <h5><?php echo $lang['head_faq']; ?> </h5> <article class="auction_container"> <article id="menu"> <?php if ($faqs) { ?> <?php foreach ($faqs as $faq) { ?> <h3><?php echo $faq['question']; ?> </h3> <p><?php echo $faq['answer']; ?> </p> <?php } ?> <?php }
function searchFAQs($search_query, $sort_type, $sort_order) { $link = AdminUtility::getDefaultDBConnection(); if (empty($search_query)) { return getFAQs($sort_type, $sort_order); } else { $FAQs = array(); //process query $fields = explode(" ", $search_query); $query = "select * from faq where "; for ($count = 0; $count < count($fields); $count++) { $query .= "question like '%{$fields[$count]}%' or " . "answer like '%{$fields[$count]}%'"; if ($count !== count($fields) - 1) { $query .= " or "; } } //Search $result = mysqli_query($link, $query); if ($result) { while ($row = mysqli_fetch_array($result)) { array_push($FAQs, $row); } } sortFAQs($FAQs, $sort_type, $sort_order); //Log error AdminUtility::logMySQLError($link); return $FAQs; } }