I am trying to insert single form value called multiple times using ajax call to mysql in php with submit all button . I have store all the forms data to localStorage. But when I am trying to insert all the values to mysql one form value is inserting and other form values is taking null value.
**loadquestions1.php**
<form method="post">
        <table>
            <tr>
                <td>
                    <?php echo "<h5>Question: ".$question_no ."</h5><h5> ".$question_title ."</h5>"; ?>
                </td>
                    
            </tr>
        </table>
        
     
    <div class="center">
    
      <textarea placeholder="Write your answer here..." class="outer persisted-text" name="pt<?php echo $question_no; ?>" id="persisted-text" onchange="changeBack();" rows="10" cols="100"></textarea>
        <span><input type="hidden" name="question_no<?php echo $question_no; ?>" value="<?php echo $question_no; ?>" /></span>
        <span><input type="hidden" name="question_title<?php echo $question_no; ?>" value="<?php echo $question_title; ?>" /></span>
    </div> 
     <button class="btn btn-success" name="save">Save</button>
    
    
<?php } ?>
</form>function load_questions1(questionno)
{
    document.getElementById("current_que").innerHTML=questionno;
    
    
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange=function() {
        if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
        {
            
            if(xmlhttp.responseText=="over")
            {
                window.location="result.php";
                alert("hello");
            }
            
            else
            {
                document.getElementById("load_questions1").innerHTML=xmlhttp.responseText;
                load_total_que();
            
    
    var supported = '',
    unsupported = 'Oh no! Your browser does not support localStorage.';
if (window.localStorage) {
    $('.persisted-text').keyup(function () {
        localStorage.setItem(this.name+questionno, this.value);
    }).val(function () {
        return localStorage.getItem(this.name+questionno) || supported
    })
} else {
    $('.persisted-text').val(unsupported);
}
    
            }
            
        }
    };
    
    xmlhttp.open("GET", "forajax/load_questions1.php?questionno="+ questionno, true);
    xmlhttp.send(null);
    
}**config.php**
if (isset($_POST['save'])) {
        
        $size = sizeof($_POST);
        $number = $size/3;
        $query = "SELECT * FROM add_question where online_exam_title='$_SESSION[add_exam]'";
        $data = mysqli_query($conn, $query);
        $count=mysqli_num_rows($data);
        
        for($i=1;$i<$count;$i++) {
      
        $index1 = 'pt'.$i;
        $pt[$i] = $_POST[$index1];
        $index2 = 'question_no'.$i;
        $question_no[$i] = $_POST[$index2];
        $index3 = 'question_title'.$i;
        $question_title[$i] = $_POST[$index3];
  //$question_no = $_POST['question_no'];
    
    $sql="INSERT INTO subjective_answer (placeholder, exam_type, username, question_no, question_title) VALUES ('$pt[$i]', '$_SESSION[add_exam]', '$_SESSION[username]', '$question_no[$i]', '$question_title[$i]')";
    
    $result=mysqli_query($conn,$sql);
  
}
  if($result)
  {
   echo "record inserted";
  }
        
} 
    