Updating Multiple Rows Within a Single Form |
Hello everybody,
I have got 2 tables on my db: Products and Productimages I'm trying to update ordering of the images on Productimages table which are related to a product: My Productimages table: imageid - imagepath - productid - ordering I reach to the update page via product id (on url: update-product-image-order/3). This update page shows only the images related to this product (in this example, it is 3) On this page I am calling images via a "foreach" and all images have the same 'name'. And, no matter what I tried, I couldn't make it. My View: PHP Code: <form role="form" method="post" action="<?php echo base_url('cp/productimageneworder'); ?>"> How should I set up my controller and my model? I would be grateful if you could show me the way.
Hi, your table has names like:
Productimage: imageid - imagepath - productid - ordering but why you use src = echo $img->imgpath02; from where you has that 02 number in imagepath? this is a example how i used the foreach styntaxis in Codeigniter 3.1.1 https://codeigniter.com/user_guide/gener...ht=foreach (01-24-2019, 10:25 AM)Eduardo-Peralta Wrote: Hi, your table has names like: Dear Eduardo-Peralta, thanks for your message. Actually that is not the reason for any mistake. Because I typed here wrong : Correcting my typo.
Following the tutorial here on YouTube I have made it work! But, I'm ready to hear any other solution or alternatives.
First add brackets to names: PHP Code: <input type="hidden" name="relatedphoto[]" value="<?php echo $img->imgid; ?>"> The Controller : PHP Code: function productimageneworder(){ As I said, Even though I've found a solution, I'm ready to see your alternatives. |
Welcome Guest, Not a member yet? Register Sign In |