I have a working IF statement, but then when I add a 'ELSE IF' to this this 'overwrites' my IF.
I will try to explain more here.
For the purpose of this example,
getNewLine() returns 6.
$noOfLines = 58.
$rotaDate = 5th Jan 2014
$line = from 1 to 58.
My initial IF statement gives correct output (adding 1 week to each line):-
//This function determines and inserts the custom column data.
function customData($line){
global $rotaDate,$noOfLines;
if($line >= getNewLine()){
$weeks=($line-getNewLine());
$modifier=$weeks.' weeks';
$rotaDate->modify($modifier);
return $rotaDate ->format("jS F Y");
}
1
2
3
4
5
6 05-Jan-14
7 12-Jan-14
8 19-Jan-14
9 26-Jan-14
10 02-Feb-14
...
...
...
...
56 21-Dec-14
57 28-Dec-14
58 04-Jan-15
So far, So good..
But now, I need to continue from 4-Jan line 58, back up to line 1, 1week later (11-Jan) down to line 5 of which would be 8th Feb.
i.e. all lines Less than getNewLine() // which is 6
To do this I have added ELSE IF:-
/* else if($line<getNewLine()) {
$weeks=($line+$noOfLines-getNewLine());
$modifier=$weeks.' weeks';
$rotaDate->modify($modifier);
return $rotaDate ->format("jS F Y");
}
*/
This the outputs from line 1 to line 5 correctly, But it continues to overwrite the dates down to line 58. It needs to stop at line 6.
1 11-Jan-15
2 18-Jan-15
3 25-Jan-15
4 01-Feb-15
5 08-Feb-15
6 15-Feb-15
7 22-Feb-15
8 01-Mar-15
9 08-Mar-15
10 15-Mar-15
11 22-Mar-15
...
...
...
... down to line 58...
Any ideas why this is happening and how I may stop this please?