Welcome Guest, Not a member yet? Register   Sign In
How to "insert" mysql from the multiple selection on Flexigrid table
#1

[eluser]jikowhitewolf[/eluser]
I follow the delete.php example to create my insert.php.

What I want is to pick the rows from 1 table and insert my multiple selections to another table.

Delete.php uses:

Code:
$items         = rtrim($_POST['items'],",");
$db_table     = "mytable_database";
$rs_check = mysql_query("SELECT * FROM $db_table WHERE `id` IN ($items)");

and it will delete everything inside "$items".

But when it comes to

Insert.php, i uses:



Code:
$userinfo = "SELECT * from $db_table WHERE id IN ($items)";    
$userinfo2 = mysql_query($userinfo) or die ("could not select user from table Error: ".mysql_error());
$userinfo3 = mysql_fetch_assoc($userinfo2);        
    
$insert_sql = "INSERT into $db_table
        (    identity,
            email
        ) VALUES (
            $userinfo3[identity],
            $userinfo3[email]
        )";    
                            
$sql_insert_selection = mysql_query($insert_sql) or die("Cannot insert into new table");

It only insert the first selection, from the multiple rows I selected.

I am still new with PHP and mySQL, Please kindly help.




Theme © iAndrew 2016 - Forum software by © MyBB