Really looking for some guidance on this one.
I am currently creating an investment management portal for an organisation.
I have created a piece of code to generate the transactions that are due (code below), however when I have now tried to use this and change the echo to an sql insert query, it only creates a single record within the mysql database
$investment_term = 12;
$repayment_term = 1; //Monthly
$funds_received = date('2021-12-07');
$repayment_amount = 100;
$repayments = $investment_term / $repayment_term;
for ($x = 1; $x <= $repayments; $x++) {
$repeat = strtotime("+$repayment_term months",strtotime($funds_received));
$funds_received = date('Y-m-d',$repeat);
//Will replace below echo lines to sql insert query (query below);
echo "<p>Payment $x of $repayment_amount due on $funds_received</p>";
}
echo "<strong> Total of $repayments repayments</strong>">
//Sql Query to replace above echo's
INSERT INTO `transactional` (`investmentid`, `amount`, `duedate`, `postedby`, `status`) VALUES ('$investment_id', '$repayment_value', '$received_date', 'system', 'new');
What should happen is that there are 12 financial transactions created within the database with the each due date being +1 months
If anyone could assist or point me in the right direction that would be greatly appreciated.