Juntar valores de tabelas
Boas. Como posso retornar todas as tags referentes a um post ?
$posts = $conn->query("
SELECT * FROM posts
LEFT JOIN tags_to_post ON posts.id = tags_to_post.post_id
LEFT JOIN tags ON tags.id = tags_to_post.tag_id");
Eu queria usar
while($post = $posts->fetch_assoc()) {
foreach($post['tags'] as $tag){
echo $tag['id'].$tag['name']
}
}Discussão (1)
Carregando comentários...