I am creating an array list with AJAX. When I query SQL I get a missing list. Array's second element is not appearing in query.
ajax.php
require_once("connection.php");
$keywords = $_POST['keyword'];
$keywords = array_map("strtolower",$keywords);
$new_keyword= implode(",",$keywords );
$query = mysqli_query($connect,"select images.image_url,keyword.keyword from keyword inner join images on images.id = keyword.id where keyword.keyword in ('$new_keyword')");
$number= mysqli_num_rows($query);
output should be 1 but 2 because $keyword = ['hi','name'];
I suspect that you incorrectly join the tables "on images.id = keyword.id". I dont know your BD schema but I suspect it should be "on images.keyword_id = keyword.id" or "on images.id = keyword.image_id" or something similar. Give us an example data i those tables as well as table definitions.
EDIT: starting from the 4th line change the code to:
$new_keyword= implode("','",$keywords );
$new_keyword = "'".$new_keyword."'";
$query = mysqli_query($connect,"select images.image_url,keyword.keyword from keyword inner join images on images.id = keyword.id where keyword.keyword in (".$new_keyword.")");
$number= mysqli_num_rows($query);