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! Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
RyanMinor Posted April 29, 2011 Author Share Posted April 29, 2011 OK thanks! I appreciate your input. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.