• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Updating several rows of db table with one post.


I apologise as I'm quite new to codeigniter but I'm going to try and explain what I'm trying to do as clearly as possible ...

I've got a lookup table called auth_document with two columns named 'username' and 'document_id'. It's used for assigning documents to users.

In my view page I use a multiple select to to assign various documents to one user. When I post this page however I don't know how to get all the contents to be written into the db. Normally I'm just inserting or updating one row of data but in this case I could be inserting several rows. My form when rendered looks something like this:

<form action="http://test.dev/admin/document_assign" method="post">
<input type="hidden" name="document_id" value="1" />
Assign this document to the following classes:
<select class="size2" type="text" name="username[]" multiple="multiple" size="4">
<option value="user1"><br />classname1</option>
<option value="user2"><br />classname2</option>
<option value="user3"><br />classname3</option>
&lt;input type="submit" value="submit" /&gt;

So when I post this data it will be one document_id and several users. If for example I select all three users to assign this document then I'd need to update 3 rows in the database. Can this insert be carried out using the active record class? Could someone help me out as to how this could be achieved?

Many thanks in advance.

Messages In This Thread
Updating several rows of db table with one post. - by El Forum - 07-22-2007, 03:42 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.