I am down to the last step of a search results with pagination page. I have it all working, but only when there is on search input text field. I need it to be able to take in multiple values for search_text since there will be several search choices. That is, how can $pagination be passed to values and do it's job as written below? All form input types on the HTML form on the page have the name search_text.
I had this working in a previous search code without pagination where I brough the multiple search queries options into the search.php like this:
//the HTML form from another page that is sending the two values
<form name="search" method="post"
action="http://example.com/search"> Seach for: <input type="text"
name="search_text[]" />
<select name="search_text[]">
<option value="Fiction" selected>Comedy</option>
<option value="Non-Fiction">Drama</option>
</select>
<input type="submit" name="search_button" value="search" /></form>
//search queries from multiple select/input fields in form
$input = array(
"search_text" => $_REQUEST['search_text'],);
$sgenre = $input['search_text'][0];
$scategory = $input['search_text'][1];
Now I need to figure out how to alter the below code (which works, but only when the html form has just one input text box named search_text. How can I make this code below accept the multiple values that I bring onto the page with the code above?
$query = "SELECT * FROM stories";
if(isset($_REQUEST["search_text"]) && $_REQUEST["search_text"] != "")
{
$search = htmlspecialchars($_REQUEST["search_text"]);
$pagination->param = "&search=$search";
$query .= " WHERE stories.genre LIKE '%$search%'";
}
$pagination->rowCount($query);
$pagination->config(3, 5);
$query .= " ORDER BY SID ASC LIMIT {$pagination->start_row},
{$pagination->max_rows}";
Perhaps something like this
$query = "SELECT * FROM stories";
if(isset($_REQUEST["search_text"]) && $_REQUEST["search_text"] != "")
{
$search = htmlspecialchars($_REQUEST["search_text"]);
$genre = htmlspecialchars($_REQUEST["search_text"][0]);
$category = htmlspecialchars($_REQUEST["search_text"][1]);
$pagination->param = "&search=$search";
$query .= " WHERE stories.genre LIKE '%$search%'";
$query .= " AND stores.genre LIKE '%$category'";
}