How do i Pass in Multiple values into the database from one input filed in CI |
[eluser]Unknown[/eluser]
hi im a newbie in CI. i have a drop-down list which pulls from values from my database table. table_name='state' have columns- id and branch_name. Drop down list looks like this: <select name="branch" > <option></option> <?php if (isset($state_array)) { foreach ($state_array as $row) { ?> <option value="<?php echo $row->id; ?>"><?php echo $row->branch_name; ?></option> <?php } } ?> </select> The above code gives a list of all the states in my database. Now, i have a second table assign_task which have columns = id, task_code, branch_name. when a user submits a value from the select drop down, it only updates the id column while the branch_name is not populated. I want the two columns, id and branch id in the assign_task table to be populated with their values once a user submits a value from the list. Does anyone know how i can get around this? Thanks
[eluser]Ninjabear[/eluser]
I think you'll need to show us your controller and model code so we can see what you are trying to do. Are you trying to add a row to the assign_task table, state table or both? In CI you can add rows to your database table using the insert method in the active record class: http://ellislab.com/codeigniter/user-gui...tml#insert
[eluser]porquero[/eluser]
You can fill value att with bith values, like: $id|$branch. So you can explode string tou insert into db. Also, I think that you should use form helpers, is more easy. http://ellislab.com/codeigniter/user-gui...elper.html See: form_dropdown() |
Welcome Guest, Not a member yet? Register Sign In |