A little help guys?
when i input list and slist the query works. but if i only input list only it doesnt show the query for finding datas with category = list, same goes for the slist if i input slist only it doesn't show the query for finding datas with subcategory = slist.
for example if i input Toys on list and boy on slist the query executes and shows the products thats category = Toys and subcategory = boys but if i only input toys in list and i didnt input anything on slist it doesnt shows the query for products that only shows toys the same thing happens if i only input slist
it only works if i input them both.. i need to make a search bar that can search for both, list only and slist only. Sorry for my bad english.
<?php
$category = $user_data['categoryquery'];
$per_page = 15;
// figure out the total pages in the database
if (isset($_POST['submit']))
{
if($_POST['list'] != '' && $_POST['slist'] != '')
$list = $_POST['list'];
$slist = $_POST['slist'];
$result = mysql_query("SELECT * FROM products WHERE category = '$list' AND subcategory = '$slist' ORDER BY date_added");
}else{
if($_POST['list'] == '' && $_POST['slist'] != '')
{
$slist = $_POST['slist'];
$result = mysql_query("SELECT * FROM products WHERE subcategory = '$slist' ORDER BY date_added");
}else{
if($_POST['list'] != '' && $_POST['slist'] == '')
{
$list = $_POST['list'];
$result = mysql_query("SELECT * FROM products WHERE category = '$list' ORDER BY date_added");
}else{
$result = mysql_query("SELECT * FROM products");
}
}
}
if($_POST['list'] != '' && $_POST['slist'] != '')?