Group according to a field problem...!!! - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Group according to a field problem...!!! (/showthread.php?tid=39198) |
Group according to a field problem...!!! - El Forum - 03-03-2011 [eluser]Roy MJ[/eluser] Can anyone tell me if its possible to group together values from a table according to a particular field. I am having five values in the table : id,name,district,workstation,state. My requirement is to group together all table entries accordong to state. It should be like this. Andra Pradesh S.No Name District Work Station State 1 Ramesh paul Warangal Warangal 2 Suresh Paul Warangal Nizanpalli 3 Battinini Sujatha Warangal Nizanpalli 4 Shalem Raju Rangareddy Vikarabadh 5 M.Shiromani Rangareddy Vikarabad 6 B.Prakash babu Warangal Gundrathimadugu 7 Bandi Pushpalatha Warangal Gundrathimadugu 8 Emmady Suresh Warangal Palakurthy 9 E.Sujatha Warangal Palakurthy 10 Arun Kumar Warangal Wardhanapet Kerala S.No Name District Work Station State 1 Ramesh paul Warangal Warangal 2 Suresh Paul Warangal Nizanpalli 3 Battinini Sujatha Warangal Nizanpalli 4 Shalem Raju Rangareddy Vikarabadh 5 M.Shiromani Rangareddy Vikarabad 6 B.Prakash babu Warangal Gundrathimadugu 7 Bandi Pushpalatha Warangal Gundrathimadugu 8 Emmady Suresh Warangal Palakurthy 9 E.Sujatha Warangal Palakurthy 10 Arun Kumar Warangal Wardhanapet where AndraPradesh, Kerala comes under the states. Can anyone tell me how to write the code so that it displays the state field once and all table entries having the particular state will be listed, then next state and corresponding entries and so on. Please help. My controller is as follows: Code: function index($pgoffset='') My model is as follows: Code: function get_total() And the view is as follows: Code: <table width="593" cellspacing="0" cellpadding="0" style="border: 1px solid rgb(0, 0, 0);"> |