0

Hi to all i experience this kind of error when i tried to add the data to database using for each here is my code.

$org   = Input::get('orgname');
        $orgs_date = Input::get('orgsattended');
        foreach($org as $o=>$von){
        DB::table('orgs')->insert(array(
            'personnel_id'           => $personnel_id,
            'orgs_name'              => $von,
            'date_attended'          => $org_date[$o]
        )
        );
        }
$skillname = Input::get('skillname');
        $skillproficiency = Input::get('skillproficiency');
        foreach($skillname as $sn=>$vsn){
            DB::table('skills')->insert(array(
                'personnel_id'       => $personnel_id,            
                'skill_name'         => $vsn,       
                'proficiency'        => $skillproficiency[$sn]       
                )
            );


    }

i need to add the data to seperate database.
when i only use one code it works.

3
Contributors
2
Replies
17
Views
3 Years
Discussion Span
Last Post by nadiam
0

Hi to all i experience this kind of error when i tried to add the data to database using for each here is my code.

What error? ARe you talking about the "invalid argument...foreach()"?

This often occurs if the "array" in the foreach statement is not actually an array for whatever reason.

i need to add the data to seperate database.
when i only use one code it works.

What are you trying to say? What separate DB? Which one code? Are you saying a single value of $skillname?

Your indenting is all over the place. Sloppy presentation of code suggests sloppy coding. I'm sure that's not the case, so please reformat your code and you may get more replies.

0

What separate DB?

i think he meant separate tables in the database. would one need multiple databases though? i didn't think multiple databases was needed in any one project.

also maybe post the html that might also help the experts here to help you out. help them, help you.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.