Group_Concat with php to add individual hyperlinks

﹥>﹥吖頭↗ 提交于 2019-12-11 22:01:52

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!