This is my code
$stmt = $conn->prepare("SELECT tmdb_movies.movie_title,tmdb_movies.tmdb_id, count (tmdb_id),GROUP_CONCAT(DISTINCT genres.genres_name) AS genres_name
FROM tmdb_movies
JOIN genres USING (tmdb_id)
GROUP BY tmdb_movies.movie_title,tmdb_movies.tmdb_id
HAVING find_in_set('$category1', genres_name) AND find_in_set('$category2', genres_name)
LIMIT $limit OFFSET $start");
// Then fire it up
$stmt->execute();
// Pick up the result as an array
$result = $stmt->fetchAll();
Since i cannot calculate total number of rows which include $category1
and $category2
in the same code, I added this code before it.
$sql = "SELECT count(tmdb_id),group_concat(genres.genres_name) AS genres_name
FROM `tmdb_movies`
JOIN genres USING (tmdb_id)
GROUP BY tmdb_movies.tmdb_id
HAVING find_in_set('$category1', genres_name) AND find_in_set('$category2', genres_name) ";
$result = $conn->prepare($sql);
$result->execute();
$totalrows = $result->rowCount();
echo $totalrows;
But $totalrows
echo 3
here. But their a lot more rows than 3.