I have a search menu with a dropdown as the first box, and a text box as the second box to search some database records.
To what I know it works. But now I want to display those results after it chooses the correct part of the code.
The code is setup as Category 1, as first section and 2-18 as other
But I want to output my array of the found results below them. I tried to code it in, but then I break my IF/ELSEIF setup.
I guess I need to nest another IF, and output my array? between the original IF but before the ELSEIF?
heres my code, on my search.php page. A few variables are passed from the previous page.
productCat
and
search_text
<?php
include('Includes/config.php');
//to save data from html form into 2 variables
$productCat = intval($_POST['productCat']);
$search_text = mysql_real_escape_string($_POST['search_text']);
//execute query
if ($productCat>1)
{
$query = "SELECT *, MATCH (prodName) AGAINST (".$search_text.") FROM `products` WHERE MATCH (prodName) AGAINST(".$search_text.") AND `productCat`= ".$productCat." ORDER BY MATCH (prodName) AGAINST (".$search_text.") DESC";
$results = mysql_query($query);
}
elseif ($productCat==1)
{
$query = "SELECT *, MATCH (prodName) AGAINST (".$search_text.") FROM `products` WHERE MATCH (prodName) AGAINST(".$search_text.") ORDER BY MATCH (prodName) AGAINST (".$search_text.") DESC";
$results = mysql_query($query);
}
?>