<?php
//print_r($_POST);
require_once('dbconnection.php');
$s_name = json_decode($_POST["s_name"]);
$s_fname = json_decode($_POST["s_fname"]);
$s_school = json_decode($_POST["s_school"]);
$s_phone = json_decode($_POST["s_phone"]);
$note = json_decode($_POST["note"]);



for ($i = 0; $i < count($s_name); $i++) {

    if(($s_name[$i] != "")){ 
        
        /* not allowing empty values and the row which has been removed. */
    $sql="INSERT INTO student (s_name,s_fname,s_phone,s_school,s_note)
VALUES
('$s_name[$i]','$s_fname[$i]','$s_phone[$i]','$s_school[$i]','$note[$i]')";
    if (!mysqli_query($con,$sql))
    {
        die('Error: ' . mysqli_error($con));
    }

    }
}


mysqli_close($con);
?>