问题
I've got a query that retrieves from tables using group_concat so that I dont have repititions.
'SELECT book_name, chapter_slug, GROUP_CONCAT(chapter_name SEPARATOR "<br/>") as ChapterNames
FROM ci_books, ci_chapters
WHERE ci_books.book_id = ci_chapters.book_id AND slug = ' . $conn->quote($slug). '
GROUP BY book_name;'
Now the results are
separated which is good because I want to add hyperlinks to each however I am only getting one row that means the hyperlink is the same for all the chapterNames values.
book_name chapter_slug ChapterNames
Twelvers Dawn wonders Wonders<br/>Rising
So now all the ChapterNames when hyperlinked via PHP are just the same. I can understand why, but how can I make it that each one has its own hyperlink.
Ideally, I would like this result or similar:
book_name chapter_slug ChapterNames
Twelvers Dawn wonders Wonders
rising Rising
movers Movers
来源:https://stackoverflow.com/questions/19907921/group-concat-with-php-to-add-individual-hyperlinks