![]() |
how can i get the particular post id in foreach loop - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: how can i get the particular post id in foreach loop (/showthread.php?tid=62173) Pages:
1
2
|
how can i get the particular post id in foreach loop - Chandini - 06-15-2015 Hi , friend .... user posts display on foreach loop .. view looking good (See the below Images) when ever try to post the comment in particular post ... it work on only first row in foreach loop .. remain post comments are not inserted .. How can i insert the particular post id's, and and user comment s in particular post ... ? I try to insert the comment in 2nd row in foreach loop the post id insert the first row id ... ?.... Only its work on first row in loop .. how can solve this problem ....? Help Me , thank u RE: how can i get the particular post id in foreach loop - Wouter60 - 06-16-2015 You should name your fields as arrays, by adding square brackets after the field's name, like this: PHP Code: <textarea name="comment_text[]" rows=3 cols=40></textarea> PHP Code: $posts = $this->input->post('post_id'); //returns an array!! RE: how can i get the particular post id in foreach loop - Chandini - 06-17-2015 (06-16-2015, 12:48 PM)Wouter60 Wrote: You should name your fields as arrays, by adding square brackets after the field's name, like this: RE: how can i get the particular post id in foreach loop - Chandini - 06-17-2015 Its not working ... Only first record in loop comment and post is inserted remain posts are empty values inserted ... RE: how can i get the particular post id in foreach loop - Wouter60 - 06-18-2015 Please add your controller and view files as attachments, not the print-screens. RE: how can i get the particular post id in foreach loop - Chandini - 06-21-2015 (06-18-2015, 08:06 AM)Wouter60 Wrote: Please add your controller and view files as attachments, not the print-screens. RE: how can i get the particular post id in foreach loop - Wouter60 - 06-22-2015 I think I found the problem. Your view builds up a series of forms (within a foreach { } loop). All forms have the same name: post_comment. In your javascript function do_something(), you submit the form with the name post_comment. Since all forms have that name, only the first one is posted. Now my question is: when the user hits the Enter key, do you want all comment-forms to be posted, or just the one where the user has filled-in some text and hit Enter? RE: how can i get the particular post id in foreach loop - Chandini - 06-23-2015 (06-22-2015, 07:13 AM)Wouter60 Wrote: I think I found the problem. When ever user write comment in particular post .. that post-id , and that post comment will be inserted in to data base show in db... Thanks for problem finding .... RE: how can i get the particular post id in foreach loop - Wouter60 - 06-24-2015 In a very compact form, your view should have this structure: PHP Code: //html header etc. Now in your controller, put this code to fetch the posted values: PHP Code: $post_id = $this->input->post('post_id[0]'); RE: how can i get the particular post id in foreach loop - Chandini - 06-25-2015 (06-24-2015, 07:37 AM)Wouter60 Wrote: In a very compact form, your view should have this structure:Wow Thanks .. Its working ... really thanks to Wouter60 ![]() |