$search_terms = 'xyz'; // collects all search terms, "xyz" creates a tag to find and replace the initial && not between two terms
if ($sort_age != 'ALL'){ // checks if search term is set, if yes adds term to cumulative terms
$search_terms = '' .$search_terms. ' && ($row[0] == $sort_age)';
}
if ($sort_gender != 'ALL'){ // checks if search term is set, if yes adds term to cumulative terms
$search_terms = '' .$search_terms. ' && ($row[1] == $sort_gender)';
}
if ($sort_status != 'ALL'){ // checks if search term is set, if yes adds term to cumulative terms
$search_terms = '' .$search_terms. ' && ($row[2] == $sort_status)';
}
require_once ('conf.php');
$query = "SELECT CONCAT(age) AS age, CONCAT(gender) AS gender, CONCAT(status) AS status, CONCAT(words_1) AS words_1 FROM userdata ORDER BY age ASC"; // pulls up all entries
$result = @ ($query);
if ($result){
$search_terms = '' .str_replace("xyz && ","",$search_terms). ''; // removes the initial && that is not between two terms and would otherwise cause an error
while ($row = mysql_fetch_array($result, MYSQL_NUM)){
[b]if ($search_terms){ // this is supposed to list the terms, but obviously isn't in correct syntax[/b]
echo "<br>" .$row[0]. "," .$row[1]. "," .$row[2]. "," .$row[3]. ""; // echos results that match search terms
}
}[/quote]
The three sort variables are coming from dropdown menus being manually sent. The idea is to show all entries in the DB, then be able to narrow them down by selecting options in each of the terms.
Everything is working fine, except parsing if ($search_terms) as the terms, and not as a NULL/!NULL statement.
What is the syntax for this? Thanks.
oed