This is probably more of a 'programming technique' question, but I'm not sure which section of SO that should go to.
I am trying to make a website of "guided questions and (available) answers" - probably easily described structurally like a 'Choose Your Own Adventure' type approach.
Rather than embarking on creating an intricate tree that outlines each and every "storyline branching" and then hard-coding the (a href) to match, I was thinking of a more dynamic "journey" which begins with an array variable that outlines the sequence of the questions that will be asked.
for example, if a user chooses Sequence A; $questionarray = [Q1,Q3,Q2,Q5,Q6] if a user chooses Sequence B; $questionarray = [Q1,Q2,Q4,Q3,Q7] and so on.
My first attempt was to try something simple, just have it in sequence like [Q1,Q2,Q3,Q4,Q5] in which case I wouldn't need an array but a simple incrementing variable, say $qnum, and each subsequent file would call the next, like so - Q1.htm calls Q2.htm, Q2.htm calls Q3.htm, but not because it has been hard-coded in each file but determined by the incrementing 'unifying variable' of $qnum. (the thought was that, if that succeeded, it would then be a simple case of replacing $qnum with the afore-mentioned array variable '$questionarray'.)
The problem then arose that over several documents, HTML or even PHP, $qnum couldn't be "carried across" to the next file - without writing to, say, a textfile on the server-side to keep track.
I even tried to change the above 'sibling call sibling' structure to 'parent call child' (via "include Q".$qnum.".php") but the $_POST/document.reload also ends up resetting the $qnum back to declared value.
Is there another method I could use that I'm not aware of - aside from writing to/reading from a server-side text file, whichh would be quite inefficient, right?