I want to create a form like in this post, but I want to make it so that if one of the inputs is empty, then the php will still process the queries. Do I use INNERJOIN or LEFTJOIN?
EDIT: This is the html form from that post:
<form action="results.php" method="GET">
<input type="text" name="input">
<input type="text" name="topic">
<input type="text" name="location">
</form>
And the php code for it:
$db = new mysqli(*your database connection information here*);
$input = $_GET['input']; //this is for the text input - ignore
$topic = $_GET['topic']; // the first select box value which works well
$location = $_GET['location']; //the second select box value which isn't being inserted into the query
$combined = $input . $topic . $location;
$terms = explode(" ", $combined);
$stmt = $db->prepare("SELECT * FROM search WHERE input = ? AND topic = ? AND location = ?");
$stmt->bind_param("sss", $input, $topic, $location);
$stmt->execute();
$stmt->close();
If the "topic" input is empty for example, I want to make it so that the SELECT query would still return a row instead of nothing
leftorinnerjoin. Please add code so we can see what you are actually doing.whereto be built dynamically? That's not whatjoins are for. You should use conditionals in the PHP to build thewhereclause dynamically.pdoinstead ofmysqli. Its placeholder(:placeholder)format is more flexible for this task.