Welcome Guest, Not a member yet? Register   Sign In
[Resolved] 2 tables in one form
#2

[eluser]xwero[/eluser]
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
Code:
<form>
<input type="text" name="field1">
<input type="text" name="field2">
<input type="submit" value="send">
</form>
controller
Code:
if(isset($_POST))
{
    // validation
    $this->load->model('Somemodel','',true);
    $this->Somemodel->insert($_POST);
}
model
Code:
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.


Messages In This Thread
[Resolved] 2 tables in one form - by El Forum - 10-22-2007, 02:32 AM
[Resolved] 2 tables in one form - by El Forum - 10-22-2007, 02:54 AM
[Resolved] 2 tables in one form - by El Forum - 10-22-2007, 02:58 AM
[Resolved] 2 tables in one form - by El Forum - 10-22-2007, 03:21 AM
[Resolved] 2 tables in one form - by El Forum - 10-22-2007, 03:52 AM



Theme © iAndrew 2016 - Forum software by © MyBB