I'm trying to create an instant search to pull the data from my database. I want it to be able to search 2 fields from 2 different tables. So far, I have it working that if you choose one specific field of either table, it will work just fine, currently; it is pulling the data and displaying it, but I want the search to be specific.
For example, let's say I have 2 tables, one is for artist, and the other one is for their records; when you type the name of the artist, it will show all the records form that artist, but if you type the date of the release alongside of the name, it will give you that specific record and it won't show others. That's how I want it to work.
Here's what I've got so far:
include 'conn.php';
$query = $_POST['query'];
$like = "'%$query%'";
$sql = mysqli_query($db, "SELECT * FROM users JOIN tshift ON users.id=tshift.uid WHERE name LIKE {$like}
LIMIT 6");
$arr = array();
while ($r = mysqli_fetch_assoc($sql))
{
$results= array();
foreach($r as $key => $val){
if(is_string($key))
$results[$key] = $val;
}
array_push($arr, $results);
}
echo json_encode(array("artist" => $arr,"album" => $arr,"release" =>$arr));