CodeIgniter Forums
Issue with database record updating: updating record inside a foreach loop? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Issue with database record updating: updating record inside a foreach loop? (/thread-25542.html)

Pages: 1 2 3


Issue with database record updating: updating record inside a foreach loop? - El Forum - 12-16-2009

[eluser]stuffradio[/eluser]
http://ellislab.com/codeigniter/user-guide/database/configuration.html

DB_Debug if set to true will display db errors.


Issue with database record updating: updating record inside a foreach loop? - El Forum - 12-17-2009

[eluser]Salvatore Formisano[/eluser]
Just a quick reply to say that I haven't solved this yet, but as soon as I'll have time to be back on it I'll write here (it seemed to me like somebody else had a similar issue?)

- Salvatore


Issue with database record updating: updating record inside a foreach loop? - El Forum - 12-23-2009

[eluser]Salvatore Formisano[/eluser]
Hey everyone, I just wanted to write down the code that is now doing the trick for me:

Code:
function reorder_photos()
    {
        foreach($_POST as $key=>$value){
            $data['position']=$value;
            $this->m__crud->update_record("photos",$key,$data);
        }
    }

the rest of the code was unaltered from my previous posts. I haven't put my hands on it since my last time on this forum, I played with it for less than 10 minutes and it now works.

Sometimes one really needs to get away from something and head to the next task, so he can then come back and realize how easy it was to get the thing done!

Thanks everyone for the support,
Salvatore