Codeigniter getting row details through link (foreach) - 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: Codeigniter getting row details through link (foreach) (/showthread.php?tid=61048) |
Codeigniter getting row details through link (foreach) - El Forum - 09-06-2014 [eluser]Unknown[/eluser] Hi everyone, I've been doing this for almost a month but I cannot figure it out on how to get the "details" of every row in my table. My table in my view is foreach. And post it in another page. By clicking the link named "Details..." on first page. for example: ive searched in first page and this is the result: ---------- column1 column1 column3 column4 column5 column6 name desc age num add Details... name2 desc2 age2 num2 add Details... When i click the first details... it would go to second page and post name, desc, age, num, add into textbox. same as the second details... Any help would be greatly appreciated. Thanks. here are my codes: my model model.php - this is my code for search data in my database table Code: public function search_equip() { ---------- my controller search.php - my code with set rules Code: function search_equipment() ---------- my view search_view_equipment.php - this is where i search data and show results with the link every row Code: <?php ---------- my second view view_equipment.php - this is where to post the data coming from first page (specific row) Note: This td's are input, i dunno how to make a code here using input Code: <?php ---------- Is it possible to get that whole data of that row and show it in another page? Specifically, I'm confused on what am I going to do, because the table is in foreach. I cannot get the value of the specific link in first page, here's my code on getting the value of links in first page but im not succesful: controller: auth.php Code: function view_equipment_details() model: addition in model.php Code: public function get_equipment_id() { Thank you in advance for any help. Hoping for a feed back. Codeigniter getting row details through link (foreach) - El Forum - 09-09-2014 [eluser]jvicab[/eluser] I think that what you need is to pass the id of the row (equipment_id) to the called function. Your controller view_equipment_details will expect one parameter: equipment_id and its header would look like: function view_equipment_details($equipment_id) That value will be passed to model function as well: public function get_equipment_id($equipment_id) and will be used to build the where clause: $array = array('id' => $equipment_id); For this to work, you should add this value to the href attribute for the detail link in your view so the controller function will receive it: echo "<td>".anchor("auth/view_equipment_details/".$item->id, 'Details...', array('class' => 'detail'))."</td>"; Codeigniter getting row details through link (foreach) - El Forum - 09-09-2014 [eluser]Unknown[/eluser] @jvicab thank you for reading my question and my post even though it's very long. Thumbs up for your answer, it works!! Thank you very much! One more thing, is it ok that my view_equipment.php would be <input>? Not in <td>? And is it ok that is it in foreach? Or is there a better way to show that detail? |