Mini Kabibi Habibi
<?php
session_start();
$con = mysqli_connect("localhost","root","","personnel");
if(isset($_POST['save_multiple_data']))
{
$username = $_POST['username'];
$hobbies = $_POST['hobbies'];
foreach($username as $index => $usernames)
{
$s_username = $usernames;
$s_hobbies = $hobbies[$index];
// $s_otherfiled = $empid[$index];
$query = "INSERT INTO hobbies (username,hobbies) VALUES ('$s_username','$s_hobbies')";
$query_run = mysqli_query($con, $query);
}
if($query_run)
{
$_SESSION['status'] = "Multiple Data Inserted Successfully";
header("Location: trainings.php");
exit(0);
}
else
{
$_SESSION['status'] = "Data Not Inserted";
header("Location: hobbies.php");
exit(0);
}
}
?>