Below I have a line of code where it states which Session a user is currently on out of the number of Total Sessions.
<h1>CREATING QUESTIONS AND ANSWERS: SESSION (AAA) <?php echo $sessionMinus ?> OF <?php echo $_SESSION['initial_count'] ?></h1>
So for example the line could read this:
CREATING QUESTIONS AND ANSWERS: SESSION (AAA) 3 OF 3
Now the problem I have is that lets say I want 3 Sessions, It should read like this:
First time user opens page: CREATING QUESTIONS AND ANSWERS: SESSION (AAA) 1 OF 3
But instead it is reading like this: CREATING QUESTIONS AND ANSWERS: SESSION (AAA) 3 OF 3
Same if lets say I want 7 Sessions, for first session it should be: CREATING QUESTIONS AND ANSWERS: SESSION (AAA) 1 OF 7 but instead it is reading like this: CREATING QUESTIONS AND ANSWERS: SESSION (AAA) 7 OF 7.
So my question is that how can I get the first session to equal 1 out of …
Below is the current code:
if(isset($_POST['sessionNum'])){
//Declare my counter for the first time
$_SESSION['initial_count'] = $_POST['sessionNum'];
$_SESSION['sessionNum'] = $_POST['sessionNum'];
}
if (!isset($_SESSION['sessionCount'])) {
$_SESSION['sessionCount'] = 1;
}
else if ($_SESSION['sessionCount'] < $_SESSION['sessionNum']) {
++$_SESSION['sessionCount'];
}
$sessionMinus = $_SESSION['sessionCount'];
UPDATE:
Below was a previous attempt which did not work as it keep stating 2 OF 4 or 2 OF 5 or 2 OF 2 and etc:
if(isset($_POST['sessionNum'])){
//Declare my counter for the first time
$_SESSION['initial_count'] = $_POST['sessionNum'];
$_SESSION['sessionNum'] = $_POST['sessionNum'];
$_SESSION['sessionCount'] = 0;
}
else if ($_SESSION['sessionCount'] < $_SESSION['sessionNum']) {
$_SESSION['sessionCount']++;
}
$sessionMinus = $_SESSION['sessionCount'];
replace this line
with this