array insert into database
<p>guys im trying to make a list of students in php and getting each of its value and insert it in the database.</p>

<pre><code>$b_lname = $_POST['bstudnt_lname'];
$b_fname = $_POST['bstudnt_fname'];
$b_mname = $_POST['bstudnt_mname'];

$department = $_POST['class_department'];
$section = $_POST['section_name'];
$year_grade = $_POST['faclty_advse_year'];

$school_id ="a3arew542q3dq";

$counter2 = 0;

$button = $_POST['add_students'];

if(isset($button)){

    foreach($b_lname as $blast =&gt; $x){ 
        $arraylname[] ="".$x;
        }  
    foreach($b_fname as $bfirst =&gt; $y){
            $arrayfname[] ="".$y;
            $counter2+=1;
        }
    foreach($b_mname as $bmid =&gt; $z){
            $arraymname[] ="".$z;
            $counter2+=1;
        }   



        for($v=0;$v&lt;=$counter2-1;$v++){

            if($arrayfname[$v]!="" &amp;&amp; $arraymname[$v]="" &amp;&amp;   $arraylname[$v]=""){

            $insert = "INSERT INTO  students(school_id,firstname,middlename,lastname,gender,department,section,year_grade) 
           VALUES('$school_id','$arrayfname[$v]','$arraymname[$v]','$arraylname[$v]','male','$department','$section','$year_grade')";

                  if(@!mysql_query($insert)){
                    die('error insert'.mysql_error());


                    }
            }



        }
</code></pre>

<p>}</p>

<p>but im having trouble if the array has no value it wont insert in the database.
i made an if statement but i guess its no use. </p>
