I have a form with multiple inputs that user can append. I am able to get all the value from the inputs using jquery ajax. My issue is how to store the array on mysql? I have read about php serialize and unserialize but not quite sure to do it on my case. Below are the codes.
Form
<form>
    <input type="text" name="name" class="name" placeholder="Name">
    <input type="text" name="age" class="age" placeholder="Age">
    <input type="text" name="gender" class="gender" placeholder="Gender">
</form>
<button type="submit" id="store" value="store">Submit</button>
<button type="button">Cancel</button>
jQuery
$('#add').click(function(){     
    $('#append > ul').append(
        '<li style="list-style: none;">'
        + '<input type="text" name="name" class="name" placeholder="Name">' 
        + '<input type="text" name="age" class="age" placeholder="Age">'
        + '<input type="text" name="gender" class="gender" placeholder="Gender">'
        + '</li>';
    );
});
$('#remove').click(function(){
    $('li:last-child').detach();
});
function store_siblings(e){
    e.preventDefault();
    var arr = [];
    var submit = $('#store').val(),
    $('input.nama').each(function(){
        arr.push($(this).val());
    });
    $('input.age').each(function(){
        arr.push($(this).val());
    });
    $('input.gender').each(function(){
        arr.push($(this).val());
    });
    $.post('../upd-siblings.php',
    {
        submit : submit,    
        arr : arr
    }, function(data){
        $('#result').html(data)
    });
}
$("#store").click(store_siblings);
After I make the serialization and echo I get:
a:6:
{
   i:0;s:7:"MY WIFE";
   i:1;s:6:"MY SON";
   i:2;s:2:"27";
   i:3;s:1:"2";
   i:4;s:4:"WIFE";
   i:5;s:3:"SON";
}
Below are the table siblings That I create on mysql:
siblings
- id
- name
- age
- gender
Can I use mysqli INSERT using the serialize values?
 
    