I will be very grateful if you could help me.
The data add to the DB only when each data-string have a unique id. It's necessary to assign the id to each string with the click on the button.
How to transform the code that variable $i increase with each click, but there is only the one string in the table at the beginning?
<?
for($i=1; $i<2; $i++):
?>
<tr>
<td>
<label>
<input type="text" name="<?=$i?>[file]" value="<? $p=$_POST[$i]; echo($p['file'])?>" >
</label>
</td>
<td>
<label>
<input type="integer" name="<?=$i?>[xx]" value="<? $p=$_POST[$i]; echo($p['xx'])?>" >
</label>
</td>
<td>
<label>
<input type="integer" name="<?=$i?>[yy]" value="<? $p=$_POST[$i]; echo($p['yy'])?>">
</label>
</td>
<td>
<button type="button" id="add">+</button>
<button type="button" id="del">-</button>
</td>
</tr>
<script>
$(document).ready(function(){
$("#add").click(function(){
<?$i=$i+1;?>
$('#dynamic').append('<tr><td><label><input type="text" name="<?=$i?>[file]" value=""></label></td><td><label><input type="integer" name="<?=$i?>[xx]" value=""></label></td><td><label><input type="integer" name="<?=$i?>[yy]" value=""></label></td><td><button type="button" class="add">+</button> <button type="button" class="del">-</button></td></tr>');
});
});
</script>
<?endfor;?>
</tbody>
</table>
<input name="sub" type="submit" value="Create a graph" style="margin: 14px">
</form>