Update multiple rows in a table |
[eluser]eironotics[/eluser]
please can anyone show me some codes, so that i can have an idea. thanks.
[eluser]stuffradio[/eluser]
Code: $data = array( http://ellislab.com/codeigniter/user-gui...tml#update
[eluser]eironotics[/eluser]
i already know that sir. what i mean is to update one or more row in a table. and do this using the check box as a selector. pls give me a sample codes. thanks
[eluser]Mellis[/eluser]
Hi, This is how I would do it: In your view: You name your input checkboxes 'id_'.$id In your controller: for each selected checkbox you explode the post key and do the update with the $exploded[1] value. Greetings, Mellis
[eluser]eironotics[/eluser]
Hi mellis, First of all thanks,to make it clearer to you heres my code. please help me im completely new with CI. Controller Contacts Code: class Contacts extends controller{ Views: Contacts_view: it is used for inserting and popping the data in the table Code: <body> Code: class contacts_model extends Model{ the probleM: how can i populate the data from the table and fill it in the form. and how to update the table based from the specified ID number from that form when the update button is submitted help me.pls.
[eluser]Mellis[/eluser]
Allright. I'm going to suggest a way to make this work. This is just a suggestion. Anybody who has a better approach, is very welcome to correct me, I want to learn, but for now I would handle it like this. I would update my model a bit: I wouldn't hardcode the $_POST in insertlist() Code: function insertlist($values){ I would replace poplist() and compareID() with a function getcontacts or something simular Code: getcontacts($id = null) I would make a view to add / edit a single contact and a different view to edit multiple contacts. In my controller i would have a method contact() and contacts() something like this: Code: public function contact($id = null) btw i have an input helper (saw it on the forum around here somewhere) that checks if I have $this->validation->input_name. If I don't have that, it returns a standard input i passed throught in the controller
[eluser]eironotics[/eluser]
ok i get your point mellis. one more thing how can i get the values of an <input> tag? is it? Code: $this->input->type('name') what if it is an array? i know im stressing you too much.. thanks, anyway.
[eluser]Mellis[/eluser]
[quote author="eironotics" date="1219159962"]ok i get your point mellis. one more thing how can i get the values of an <input> tag? is it? Code: $this->input->type('name') what if it is an array? i know im stressing you too much.. thanks, anyway.[/quote] I don't quite get what you are asking. If you want to use $this->input->post('contact_name') just use it wherever you need it, or assign it to a variable. ($var = $this->input->post('name') if you explode your input: $contact_name = explode('_',$this->input->post('contact_name')); you can use the result like this: $contact_name[1] //(or whatever part you might need) btw you're not stressing me. You're only asking questions. If I have the time and a possible answer, I'm glad to try and help.
[eluser]eironotics[/eluser]
yeah thanks mellis. I was able to store all the values in <input> tag in an array. then i use a foreach loop to compare the id into the table. thanks, |
Welcome Guest, Not a member yet? Register Sign In |