I have 2 tables on database, table 'songs', and 'genre'.
- Table 'songs' has 3 columns: id_song (PK), song_title, lyric, id_genre
- Table 'genre' has 2 columns: id_genre (PK), genre
in table 'genre', i have:
|| id_genre | genre ||
||.......1.......|..pop...||
||.......2.......|..rock..||
||.......3.......|..jazz...||
||.......4.......|.classic.||
Relation between 2 tables:
song.id_genre FK to genre.id_genre
I have a variable like this:
$search_genre = 'pop';
and I want to search song by $search_genre
.
$query = mysql_query("SELECT song.id_song, song.song_title, genre.genre FROM song WHERE genre='$search_genre' INNER JOIN genre ON song.id_genre=genre.id_genre ORDER BY id_song");
But, it doesn't work. What should I do? Thanks for your help.
Question 2: How to show the result in php?