Welcome Guest, Not a member yet? Register   Sign In
How to insert into multiple rows in database
#1

[eluser]wasconet[/eluser]
I am designing a school attendance script, views looks like this
Code:
<form acti echo base_url(); ?>teachers/attendance' method='post'>
                <tr>
                    <thead>
                        <th class="first" width="10%">S/No.</th>
                        <th>Name</th>
                        <th>Present/Absent</th>
                        <th>Remark</th>
                    </thead>
                </tr>
               &lt;?php
               $x=1;
               foreach($teachers as $teacher)
               {$teacher_id=$teacher['teacherID'];
                echo "<tr><td>".$x."</td>";
                echo "<td>".$teacher['name']."</td>";
                echo "<td>&lt;input type='checkbox' name='attendance[$teacher_id]' value='1'/&gt;&lt;/td>";
                echo "<td>&lt;input type='text' name='remark[$teacher_id]'/&gt;&lt;/td></tr>";
                $x++;
               }
               ?&gt;
             &lt;input type="submit" name="submit" value="send" /&gt;              
            &lt;/form&gt;


when the submit button is clicked i get a data like this:
Code:
Array
(
    [attendance] => Array
        (
            [1] => 1
            [2] => 1
            [3] => 0
            [4] => 1
            [5] => 1
            [6] => 0
            [7] => 0
            [8] => 1
        )

    [remark] => Array
        (
            [1] =>
            [2] =>
            [3] =>  'sick'
            [4] =>
            [5] =>
            [6] =>  'leave'
            [7] =>  'On assignment'
            [8] =>
        )

The table i want to insert it to looks like this:

teachers table

teacher_id, date, status, remark.

i want to kknow how i can insert the above data into this table.

Thanks...
NOTE: i limited the number of teachers to 8 just for illustration, also omitted the date which will be CURDATE(), the I to 8 are the teachers ID (teacher_id)




Theme © iAndrew 2016 - Forum software by © MyBB