I have a database with only one table which has around 2 Million rows and 60 columns. I created a php application with multiple search filters like name, country, state, surname, domain etc which will filter and display the result in HTML table.
But the problem is, every text field is accepting only one input. I want to give multiple inputs in every text field separated by commas.
Eg: If I search for name: Harry Job: marketing I get the results . But i want a solution for City: Mumbai Job: marketing, Webdesigners, QA. (Multiple inputs)
Php code for sql query.
<?php
$res = false;
if(isset($_REQUEST['submit'])){
$FirstName=$_POST['FirstName'];
$LastName=$_POST['LastName'];
$Function=$_POST['Function'];
$State=$_POST['State'];
$Country =$_POST['Country'];
$Website =$_POST['Website'];
$sql=" SELECT * FROM hz WHERE FirstName like '%".$FirstName."%' AND LastName LIKE '%".$LastName."%' AND Function LIKE '%".$Function."%' AND State LIKE '%".$State."%' AND Country LIKE '%".$Country."%' AND Website LIKE '%".$Website."%'";
$q=mysqli_query($con, $sql);
}
else{
$res = true;
}
?>
Php Search Filter code
<form method="post" class="search">
<table width="200">
<td>
<tr><input class="form__input" type="search" name="FirstName" placeholder="First Name" value="<?php if(isset($FirstName)) echo $FirstName;?>" /></tr>
<tr><input class="form__input" type="search" name="LastName" placeholder="Last name" value="<?php if(isset($LastName)) echo $LastName;?>" /></tr><BR>
<tr><input class="form__input" type="search" name="Function" placeholder="Function" value="<?php if(isset($Function)) echo $Function;?>" /></tr><BR>
<tr><input class="form__input" type="search" name="State" placeholder="State" value="<?php if(isset($State)) echo $State;?>" /></tr><BR>
<tr><input class="form__input" type="search" name="Country" placeholder="Country" value="<?php if(isset($Country)) echo $Country;?>" /></tr><BR>
<tr><input class="form__input" type="search" name="Website" placeholder="Website" value="<?php if(isset($Website)) echo $Website;?>" /></tr><BR>
<tr><input type="submit" name="submit" value=" Search " class="button"/></tr>
</td>
</table>
Ps: $con = mysqli_connect("host","user","password", "databasename");