Q:

trying to insert data out of a while loop (php) in mysql

I've making a project that allows a dokter to add a treatment to a patient. I've a few treatments basic treatments added to my project.
When a dokter wants to add 1 particular treatment to a patient he can get that basic treatment and add some extra text or change the date (for exemple: patient can go home on day 4 instead of day 5). 
The issue is, is when I want to save that while loop only my last entry will get saved. Note I dont want the basic treatment to be updated but saved in another table
atm the moment I've following code: This shows the basic treatment that the docter can edit
<?php 
    echo '<form action="" method="post">';  

    while ($topic = $resul -> fetch_assoc())
    {

        $datumNew = strtotime($datum);
        $stopdate_extra=$datumNew+$topic['Dag']*84600;
        $stopdate_Nu=date("l", $stopdate_extra);
        $stopdate_Nu1=date("d", $stopdate_extra);
        $stopdate_Nu1a=date("M", $stopdate_extra);
        $stopdate_Nu2=date("Y", $stopdate_extra);
        $stopdate_db=date("Y-m-d",$stopdate_extra);

        echo "<div class='tijdlineElement'>";                   
        echo "<div class='tijdlineP2Element' ><input type='text' name='bescValue' value='" .$topic['Uur'].  "'/><br /><br /><textarea  maxlength='400' style='width:100%; height:70px;' name='uurValue' rows='4'>" . $topic['Beschrijving']. "</textarea></div>";
        echo "<div class='tijdlinePElement' style='background-color: gray;'>".  $stopdate_Nu  . '<br/> '.  $stopdate_Nu1  .' ' .  $stopdate_Nu1a  . '<br/>  '.  $stopdate_Nu2  . ' '."</div>";
        echo "<input type='hidden' name='dagValue' value='" .$stopdate_db.  "'/>"; echo "</div><br />";
      }
     echo '<br/><br/>
    <input id="btnbehandeling" name="btnbehandeling" value="voegtoe" type="submit" class="button" style="width: 101%" />
    </form>';

When he clicks on the button The following function will execute
    if(!empty($_POST['dagValue']))
{
    $obj_subscriber = new behandeling();
    $obj_subscriber->RRN = $_SESSION['patientRRN'];

    //$obj_subscriber->Dag = $_POST['date'];
    $obj_subscriber->Dag = $_POST['dagValue'];
    $obj_subscriber->Uur = $_POST['bescValue'];
    $obj_subscriber->Beschrijving = $_POST['uurValue'];

    try
    {
        $obj_subscriber->VoegBehandelingtoeTijdslijn();
        header("location: tijdslijn.php");
    }
    catch(Exception $e)
    {
        $feedback = $e->getMessage();   

    }   
}

With VoegBehandelingtoeTijdslijn
Public function VoegBehandelingtoeTijdslijn(){

            include 'PHP/Connection.php';

        $sql= "INSERT INTO tijdslijn
            (
            Beschrijving,
            User,
            Dag,
            Uur
            ) 
            VALUES 
            (

            '" . $conn-> real_escape_string($this -> m_sBeschrijving) . "',
            '" . $conn-> real_escape_string($this -> m_sRRN) . "',
            '" . $conn-> real_escape_string($this -> m_sDag) . "',
            '" . $conn-> real_escape_string($this -> m_sUur) . "'
            );";

                    if (!$conn-> query($sql)) {
        throw new Exception("Fout bij registartie");
    }

}

If i want to add the treatment 'test' which has 2 rows it will only save my last row. So my question is: How can i save all the rows that are echo'd in my while loop? 

A:

define an array outside of the loop and push each item in it then save it again. when you are doing it like you do only the last item of the loop is saved/stored. since you keep overwriting the previous item.
psuedo code
$saveddata = array();
loop{
//with one or two pieces of data.
array_push($saveddata, $data);
//with multiple pieces of data it is recommended to save it in an object first.
//and then add these objects to the array.
}

Now each found piece of data is added to this array. To unload the data loop though this array again. 

