Welcome Guest, Not a member yet? Register   Sign In
How do multiple inserts in database?
#1

[eluser]Unknown[/eluser]
Hello, I can't do a multiple inserts in database from array.

The array $user['user'] is confromed like a list. No other data inside the array only the niks.

So I need insert that list in database.

I have:
Code:
$users = $_POST['users'];
$users = trim(strtolower($users));
$users = preg_replace("/[^a-z0-9, \"']/", '', $users);
$users = preg_replace("/,[^a-z0-9]*,/", ',', $users);
$users = rtrim($users, ',');
$users = explode(',', $users);
        
$this->load->model('add_users','', TRUE);
$this->add_users->insert_users($users);

Code:
function insert_users($users)
    {
        //INSERT USERs
        foreach ($users as $user):
        $data = array(
               'user_id' => 'NULL' ,
               'user_nick' => $user
            );

        $this->db->insert('table_users', $data);
        endforeach;
    }


Messages In This Thread
How do multiple inserts in database? - by El Forum - 09-13-2008, 11:26 AM
How do multiple inserts in database? - by El Forum - 09-13-2008, 01:04 PM
How do multiple inserts in database? - by El Forum - 09-13-2008, 01:31 PM
How do multiple inserts in database? - by El Forum - 09-13-2008, 01:55 PM
How do multiple inserts in database? - by El Forum - 09-13-2008, 02:30 PM



Theme © iAndrew 2016 - Forum software by © MyBB