Php 将行添加到HTML表&;添加到数据库后

Php 将行添加到HTML表&;添加到数据库后,php,mysql,sql,Php,Mysql,Sql,我有一个将行插入数据库的表。当前限制为2行: <form action='insert-expenses.php' method='post'> <input type='hidden' value='$taskid' name='taskid'> <table width='655' border='1'> <tr><td align='left' width='350'><input type='text' name=

我有一个将行插入数据库的表。当前限制为2行:

 <form action='insert-expenses.php' method='post'>
 <input type='hidden' value='$taskid' name='taskid'>
 <table width='655' border='1'>
 <tr><td align='left' width='350'><input type='text' name='expense1' style='padding:2px;' size='80'></td><td align='center' width='100'><input type='text' name='expensecost1' style='padding:2px;' size='6'></td></tr>
 <tr><td align='left' width='350'><input type='text' name='expense2' style='padding:2px;' size='80'></td><td align='center' width='100'><input type='text' name='expensecost2' style='padding:2px;' size='6'></td></tr>
 <tr><td align='left' colspan='2'><input style='margin-top: 15px;' type='image' name='submit' src='http://bitrix24.co.uk/demo/report/add-week.jpg' ></td></tr>
 </table>
因此,我基本上希望用户单击一个按钮,向html表中添加一行,然后按另一个按钮将其添加到数据库中。我只是不知道如何识别添加的每一行的POST['inputname']


非常感谢您的帮助

请不要使用数字名称 您应该在名称中放入一个数组,如

<input name="expense[]".../>
其中,$expense将是一个数组,其元素中包含所有输入值

 <button type="button" onclick="displayResult()">Insert new row</button>
sql3="INSERT into b_report_expenses (USER_ID,EXPENSE_ONE,EXPENSE_TWO,COST_ONE,COST_TWO)
VALUES
 ('$_POST[taskid]','$_POST[expense1]','$_POST[expense2]','$_POST[expensecost1]','$_POST[expensecost2]')";
<input name="expense[]".../>
$expense = $_POST['expense'];