Answer the question
In order to leave comments, you need to log in
How to make a query to the database?
There are search parameters in GET for a database request: search.php?lic=0§ion=1,2&type=1,2,3,4
One of the 3 parameters will be mandatory, but any other two may not be. How to query the database?
For example I do this:
SELECT `id`
FROM `content`
WHERE lic='".$lic."' AND section='".$section."' AND type='".$type."'
Answer the question
In order to leave comments, you need to log in
What are variables equal to if they are not present in the query? If the value is an empty string, then you can write it like this:
$req = $mysqli->prepare(
"SELECT `id` FROM `content` ".
"WHERE ('' = ? OR `lic` = ?) ".
"AND ('' = ? OR `selection` = ?) ".
"AND ('' = ? OR `type` = ?)"
);
$req->bind_param('ssssss', $lic, $lic, $selection, $selection, $type, $type);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question