I've already created a search bar wherein users can enter keywords to search for but I also placed radio buttons below it so that when they enter their keyword, the search results would immediately filter it.
Here is what it looks like in the page
Here is my index.php:
<section id = "search">
<div class="container">
<form action="search.php">
<input type="text" name= "Search" id="Search" placeholder="Enter a keyword">
</form>
</div>
</section>
<!--radio buttons and checkbox-->
<section id="sort">
<div class="container">
<form action="search.php">
<input type="radio" id="all" name="Search" value="all" checked>
<label for="all">All</label><br><br>
<input type="radio" id="subject" name="Search" value="subject">
<label for="subject"> Subject/s : </label><br>
<input type="checkbox" id="english" name="Search" value="English">
<label for="subject">English</label>
<input type="checkbox" id="science" name="Search" value="Science">
<label for="subject">Science</label>
<input type="checkbox" id="math" name="Search" value="Math">
<label for="subject">Math</label>
</form>
</div>
</section>
Here is my search.php:
<?php
include "databaseconnect.php";
$keywordfromform = $_GET["Search"];
$sql = ("SELECT titleID, authorsID, yearID, subjectID
FROM researchpapertable
WHERE titleID LIKE '%" . $keywordfromform . "%'
OR authorsID LIKE '%" . $keywordfromform . "%'
OR yearID LIKE '%" . $keywordfromform . "%'
OR subjectID LIKE '%" . $keywordfromform . "%'
");
$result = $mysqli->query($sql);
if ($result-> num_rows>0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
echo '<tr><td><a href="upload.php">'. $row["titleID"]."</a></td><td>". $row["authorsID"]."</td><td>". $row["yearID"]."</td><td>". $row["subjectID"]."</td></tr>";
}
} else {
echo "<tr><td> 0 results </td><td> 0 results </td><td> 0 results </td><td> 0 results </td><tr>";
}
$mysqli->close();
?>
What do I need to add in order for it to filter its search as well? It works when I enter a keyword but it does not recognize what I have placed in the buttons.
I am not sure what I should search for in order to search for similar tutorials/code. If there are similar questions/code to this, it would help a lot.
This is my first site so thank you in advance!
