I am using below code to store data in table.
public function insert_pay_slip_data($data,$com_name)
{
$con = $this->__construct();
$data = explode(',', $data[0]);
foreach ($data as $value)
{
$sql = "INSERT INTO `pay_slips`(`paye_id`, `trade_id`, `inv_pdf`, `created_date`,
`created_by`) VALUES (LAST_INSERT_ID(), '".$com_name."','".$value."',NOW(),'".$_SESSION['email']."')";
$execute = mysqli_query($con, $sql);
return $execute;
}
}
On print_r($data) i am getting all files that i am uploading from view:
Array ( [0] => 6650f7.pdf [1] => 34a3f.pdf [2] => 169512017.pdf )
I am getting this array in $data. So my concern is to store each file in different row with different primary keys.
But In for each loop $data only shows last uploaded file and in db only last file is inserted. Please help me to solve this issue.