phoenixx Posted November 23, 2010 Share Posted November 23, 2010 I'm trying to increase the variables $schedulemonth, $scheduledate, $scheduleyear in each loop so that they look like $schedulemonth1, $schedulemonth2, $schedulemonth3, etc... for each of them. I've tried several options and know I'm on the right track, but no go. The customer will choose how many payments and the script below will loop that many times - I have that part working - but the calendar I'm using with the variables above is the issue. Here's the code I'm using. while ($balance > 0){ if ($balance>$monthlypayment){ $myCalendar = new tc_calendar("date" . $paymentnumber, true);$myCalendar->setIcon("images/iconCalendar.gif");$myCalendar->setDate($scheduledate, $schedulemonth, $scheduleyear); //output the calendar $myCalendar->writeScript(); echo " "; echo "<input type=\"text\" name=\"payment" . $monthlypayment . "\" value=\"" . $monthlypayment . "\">\n"; $paymenttotal=($monthlypayment+$paymenttotal); $balance=round(($invoicetotal-$paymenttotal),2); echo " Balance: $balance\n"; $schedulemonth++; if ($schedulemonth==13){ $schedulemonth=1; $scheduleyear=($scheduleyear+1); } echo "<br>\n"; } if ($balance<$monthlypayment||$balance==$monthlypayment){ $myCalendar = new tc_calendar("date" . $paymentnumber, true);$myCalendar->setIcon("images/iconCalendar.gif");$myCalendar->setDate($scheduledate, $schedulemonth, $scheduleyear); //output the calendar $myCalendar->writeScript(); echo " "; echo "<input type=\"text\" name=\"payment" . $paymentnumber . "\" value=\"" . $balance . "\">\n"; $paymenttotal=($balance+$paymenttotal); $balance=round(($invoicetotal-$paymenttotal),2); echo " Balance: $balance\n"; $schedulemonth++; if ($schedulemonth==13){ $schedulemonth=1; $scheduleyear=($scheduleyear+1); } echo "<br>\n"; } } Additionally it needs to pick up each of these variables on the next page the variables are part of hidden fields in an form later in the page. So my question is actually 3 fold. 1. How do I increase the variable count in the loop above. 2. How do I put the <input type="hidden".......> in the form so that it loops through and catches the increasing variables 3. How do I loop through on the insertion page after the form is submitted to catch how many inserts to the database are needed. This one has me bent over. Quote Link to comment Share on other sites More sharing options...
trq Posted November 23, 2010 Share Posted November 23, 2010 You would be much better off using arrays instead of variable variables, allot more efficient. Quote Link to comment Share on other sites More sharing options...
rwwd Posted November 23, 2010 Share Posted November 23, 2010 You would be much better off using arrays instead of variable variables, allot more efficient. I never got on with, nor understood the point of variable vars. IS there a point to them, can they be used in the correct context, are they beneficial? Yes, arrays ARE invaluable. Just adding my 10p there. Rw Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.