How can the issue of only the first value being saved in the database be resolved in the PHP code?

Issue: The problem of only the first value being saved in the database can be resolved by looping through the form data and inserting each value individually into the database.

// Loop through the form data and insert each value into the database
foreach ($_POST['values'] as $value) {
    // Sanitize the input data
    $value = mysqli_real_escape_string($conn, $value);
    
    // Insert the value into the database
    $query = "INSERT INTO table_name (column_name) VALUES ('$value')";
    mysqli_query($conn, $query);
}