I keep getting an extra row of data and don't know why. I have a script that first asks how many rows are need, it then makes the number of rows, then I submit that and validate the data and reproduce it, but I get an extra row for some reason
I know it's not the validation code, because it does the same without it present
here's the code from the part that draws up the rows
if (isset($_POST['submit']) && $_POST['submit'] == 'Generate Form'){
for ($i = 0; $i < $_POST['num_rows']; $i++)
{
echo '
<tr>
<td>' . $i . '</td>
<td><input type="text" name="' . $i . '[creditor]"></td>
<td><input type="text" name="' . $i . '[refno]"></td>
<td><input type="text" name="' . $i . '[amount]"></td>
<td><input type="text" name="' . $i . '[minimum]" size="12"></td>
<td><input type="text" name="' . $i . '[rate]" size="5"></td>
</tr>
';
}
echo '
</table>
<input type="submit" name="submit" value="submit">
</form>
';
}
if (isset($POST['submit']) && $POST['submit'] == 'submit')
{
foreach ($_POST as $key => $value)
{
$creditors['' . $key . ''] = '' . $value['creditor'] . '';
$refnum['' . $key . ''] = '' . $value['refno'] . '';
$amountdue['' . $key . ''] = '' . $value['amount'] . '';
$minimumdue['' . $key . ''] = '' . $value['minimum'] . '';
$interest['' . $key . ''] = '' . $value['rate'] . '';
}
array_multisort($interest, SORT_DESC, SORT_NUMERIC, $amountdue, SORT_DESC, SORT_NUMERIC, $minimumdue, SORT_DESC, SORT_NUMERIC, $creditors, SORT_ASC, SORT_REGULAR, $refnum, SORT_ASC, SORT_REGULAR);
for ($i = 0; $i < count($interest); $i++)
{
$k= $i +1;
echo'
<tr>
<td>' . $k . '</td>
<td>' . $creditors['' . $i . ''] . '</td>
<td>' . $minimumdue['' . $i . ''] . '</td>
</tr>
';
}
echo'</table>';
}
In the meantime I placed into the code:
print_r($creditors);
echo'<br />';
print_r($amountdue);
echo'<br />';
and I got the following result:
Array ( [0] => ygvjhvb [1] => jhgvjh [submit] => s )
Array ( [0] => 5686 [1] => 786 [submit] => s )