RyanMinor Posted April 29, 2011 Share Posted April 29, 2011 hello, i have a table in a database that stores information on powerpoint presentations like so: id, title, filename, presenter, program, session I want to query the data so that all entries are grouped by session (which is a date) and each presentation is displayed under its respective session in a table like so: [session] (i want to display each session once) [title] - [program] (then i want to display this information for each presentation in each session) [presenter] [session] [title] - [program] [presenter] etc... i am thinking of using group_concat for this but am not sure exactly how to pull it off. any help is greatly appreciated. thank you! Link to comment https://forums.phpfreaks.com/topic/235100-displaying-group-by-data/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 29, 2011 Share Posted April 29, 2011 You would use ORDER BY session to get the rows in the order that you want, then in your php code, you would output the new heading any time the session value changes. See this link for some pseudo code - http://www.phpfreaks.com/forums/index.php?topic=331304.msg1559057#msg1559057 Link to comment https://forums.phpfreaks.com/topic/235100-displaying-group-by-data/#findComment-1208230 Share on other sites More sharing options...
RyanMinor Posted April 29, 2011 Author Share Posted April 29, 2011 Thanks for that information. I also found this after I posted my question: http://www.outshine.com/blog/2007/04/mysqls-group-concat-in-php.php. The reason I ask about GROUP_CONCAT is because I read somewhere that it is faster. Link to comment https://forums.phpfreaks.com/topic/235100-displaying-group-by-data/#findComment-1208238 Share on other sites More sharing options...
PFMaBiSmAd Posted April 29, 2011 Share Posted April 29, 2011 Since you are going to be formatting the information using HTML, it is best to just retrieve the data you want in the order that you want it. Link to comment https://forums.phpfreaks.com/topic/235100-displaying-group-by-data/#findComment-1208243 Share on other sites More sharing options...
RyanMinor Posted April 29, 2011 Author Share Posted April 29, 2011 OK thanks! I appreciate your input. Link to comment https://forums.phpfreaks.com/topic/235100-displaying-group-by-data/#findComment-1208264 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.