Già, l'ipotesi di creare 15 diverse condizioni l'avevo considerata, ma speravo ci fosse un'altro modo...
Comunque, anche così (sgrunt!) non funziona!
Ho fatto
ma non funge...Codice PHP:
if ($title !== "" && $text == "" && $tag == "" && $location == "") {
$result = mysql_query("SELECT * FROM `news` WHERE `title` LIKE '%$title%' ORDER BY `news_id` DESC");
} else if ($text !== "" && $title == "" && $tag == "" && $location == "") {
$result = mysql_query("SELECT * FROM `news` WHERE `text` LIKE '%$text%' ORDER BY `news_id` DESC");
} else if ($tag !== "" && $text == "" && $title == "" && $location == "") {
$result = mysql_query("SELECT * FROM `news` WHERE `tag` LIKE '%$tag%' ORDER BY `news_id` DESC");
} else if ($location !== "" && $text == "" && $tag == "" && $title == "") {
$result = mysql_query("SELECT * FROM `news` WHERE `location` LIKE '%$location%' ORDER BY `news_id` DESC");
} else if ($title !== "" && $text !== "" && $tag == "" && $location == "") {
$result = mysql_query("SELECT * FROM `news` WHERE `title` LIKE '%$title%' && `text` LIKE '%$text%' ORDER BY `news_id` DESC");
} else if ($title !== "" && $text == "" && $tag !== "" && $location == "") {
$result = mysql_query("SELECT * FROM `news` WHERE `title` LIKE '%$title%' && `tag` LIKE '%$tag%' LIKE '%$location%' ORDER BY `news_id` DESC");
} else if ($title !== "" && $text == "" && $tag == "" && $location !== "") {
$result = mysql_query("SELECT * FROM `news` WHERE `title` LIKE '%$title%' && `location` LIKE '%$location%' ORDER BY `news_id` DESC");
} else if ($title == "" && $text !== "" && $tag !== "" && $location == "") {
$result = mysql_query("SELECT * FROM `news` WHERE `tag` LIKE '%$tag%' && `text` LIKE '%$text%' ORDER BY `news_id` DESC");
} else if ($title == "" && $text !== "" && $tag == "" && $location !== "") {
$result = mysql_query("SELECT * FROM `news` WHERE `location` LIKE '%$location%' && `text` LIKE '%$text%' ORDER BY `news_id` DESC");
} else if ($title == "" && $text == "" && $tag !== "" && $location !== "") {
$result = mysql_query("SELECT * FROM `news` WHERE `tag` LIKE '%$tag%' && `location` LIKE '%$location%' ORDER BY `news_id` D?????iESC");
} else if ($title !== "" && $text !== "" && $tag !== "" && $location == "") {
$result = mysql_query("SELECT * FROM `news` WHERE `title` LIKE '%$title%' && `tag` LIKE '%$tag%' && `text` LIKE '%$text%' ORDER BY `news_id` DESC");
} else if ($title !== "" && $text !== "" && $tag == "" && $location !== "") {
$result = mysql_query("SELECT * FROM `news` WHERE `title` LIKE '%$title%' && `text` LIKE '%$text%' && `location` LIKE '%$location%' ORDER BY `news_id` DESC");
} else if ($title !== "" && $text == "" && $tag !== "" && $location !== "") {
$result = mysql_query("SELECT * FROM `news` WHERE `title` LIKE '%$title%' && `tag` LIKE '%$tag%' && `location` LIKE '%$location%' ORDER BY `news_id` DESC");
} else if ($title == "" && $text !== "" && $tag !== "" && $location !== "") {
$result = mysql_query("SELECT * FROM `news` WHERE `tag` LIKE '%$tag%' && `text` LIKE '%$text%' && `location` LIKE '%$location%' ORDER BY `news_id` DESC");
} else if ($title !== "" && $text !== "" && $tag !== "" && $location !== "") {
$result = mysql_query("SELECT * FROM `news` WHERE `title` LIKE '%$title%' && `tag` LIKE '%$tag%' && `text` LIKE '%$text%' && `location` LIKE '%$location%' ORDER BY `news_id` DESC");
}
![]()