I'm working on a genre system and would like to know how I can get "names" from one table through the set of ids in another specific field.
Let's suppose that this column refers to the ids of the genres to which this video belongs:
| genres
| 1,2,3 <--- This field for example.
| 5,9,10
And I still have the table of genres being something like this:
| genre_id | genre_title
| 1 | Comedy
| 2 | Romance
| 3 | School
I want to turn that field into something like this:
Comedy, Romance, School
And I'm using a php code like this to get the information filtered by gender.
$conn = mysqli_connect("$host","$dbuser","$dbpw","$db");
if (mysqli_connect_errno()){
echo "Falha ao ligar à Base de Dados: " . mysqli_connect_error();
}
$gender = $_GET['g'];
$getGender = "FIND_IN_SET('$gender',a_generos) = $gender";
$result = mysqli_query($conn, "SELECT * FROM tblAnimes WHERE $getGender") or die(mysqli_error($conn));
while ($home = mysqli_fetch_assoc($result)){
echo "Name: " . $home['a_titulo'];
echo "Publication date: " . $home['a_dia'];
echo "Genres IDs (por agora): " . $home['a_generos']; //Get something like this (1,2,3) but i want this (Comedy, Romance, School)
}
?>
The main question is how do I turn it (1,2,3) into it (Comedy, Romance, School).