• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Resolved] 2 tables in one form

I want to update 2 tables using a single form.How can I do this?

like I want to distribute information in 2 tables using single form.

Forms aren't coupled with database tables. Forms just gather information from the user and you have to program how that information gets stored.
view file
<input type="text" name="field1">
<input type="text" name="field2">
<input type="submit" value="send">
    // validation
function insert($post)
    $this->db->query('insert into table1 (field1) values (?)',array($post['field1']));
    $this->db->query('insert into table2 (field1) values (?)',array($post['field2']));

This is example code so don't use this for production sites. I hope this gets you on your way.

u rocks...

Is it necessary to use model?.What is that some model.I'm new to this CI.


Here I want to insert top 2 fields in one table and other in second.I'm using CI validation class.

Thank you for fast reply.

Models are where you store all the functions that have to do with database manipulation. It is a part of the MVC pattern which is used by CI to create easier to maintain sites. CI does other things too but this is the heart of the framework.

The creation of models isn't much different that creating a controller you just extend the Model class instead of the Controller class.

now I got it..Thank you

I like model approach.It help me creating what I want.

U rocks man

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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