My Current Database Structure:
`images` `tags` `images_tags`
________________ ______________ ________________________
| id | title | | id | name | | id | image_id | tag_id |
|----|-----------| |----|---------| |----|----------|--------|
| 1 | Ivysaur | | 1 | fire | | 1 | 2 | 1 | Charizard: fire
| 2 | Charizard | | 2 | flying | | 2 | 2 | 2 | Charizard: flying
| 3 | Squirtle | | 3 | water | | 3 | 1 | 4 | Ivysaur: grass
| 4 | Pidgey | | 4 | grass | | 4 | 4 | 2 | Pidgey: flying
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
I want to output tags with their respective values (name).
if ($_GET["pokemon"] == "2") {
// output Charizard's tags: fire, flying
}
But I am struggling at coming up with a proper query to do this. INNER JOIN is unfamiliar to me and an explanation on how it works would be very helpful.
Pokemon. LOL! xD
To output tags:
mysql_real_escape_string($_GET['pokemon'])since you do not want SQL injection)Now a shortcut: