Hello,
This is a simple thing but somehow I can't work it :((((
I have a self-submitting form displaying data from a database. To keep
track which data to show I want to create a variable that keeps track
how many times the page is visited.
The idea is:
first call to page:var is not set => set var=0,
subsequent calls:
depending on the way the page was called* add or subract 1 from var
(provided var is respectively < nrofrecords in database and < 0).
*via a submit button called 'next page' or 'previous page'
The code:
// test 1
echo"\$Submit = ".$Submit." - \$questionCount er =
".$questionCoun ter."<br>";
if($questionCou nter==NULL)
$questionCounte r=0;
elseif($Submit= ="previous page")
$questionCounte r=$questionCoun ter>0?$question Counter-1:$questionCoun ter;
elseif($Submit= ="next page')
$questionCounte r=($questionCou nter<getNumberO fQuestions($cat egory_id)-1)?$questionCou nter+1:$questio nCounter;
//test 2
echo"\$question Counter: ".$questionCoun ter."<br>";
[color=blue]
>getNumberOfQue stions($categor y_id) correctly returns amount of[/color]
questions in db;[color=blue]
>values for $Submit is set;
>first call to $questionCounte r gives ""
>second call to $questionCounte r gives 0
>session.auto_s tart=1 in php.ini[/color]
$questionCounte r never adds up. Always when I call the page via the
'next page' button the initial value of $questionCounte r ="", after
the code it's 0
What's wrong - how can I make this work?
Thanks,
Marc
This is a simple thing but somehow I can't work it :((((
I have a self-submitting form displaying data from a database. To keep
track which data to show I want to create a variable that keeps track
how many times the page is visited.
The idea is:
first call to page:var is not set => set var=0,
subsequent calls:
depending on the way the page was called* add or subract 1 from var
(provided var is respectively < nrofrecords in database and < 0).
*via a submit button called 'next page' or 'previous page'
The code:
// test 1
echo"\$Submit = ".$Submit." - \$questionCount er =
".$questionCoun ter."<br>";
if($questionCou nter==NULL)
$questionCounte r=0;
elseif($Submit= ="previous page")
$questionCounte r=$questionCoun ter>0?$question Counter-1:$questionCoun ter;
elseif($Submit= ="next page')
$questionCounte r=($questionCou nter<getNumberO fQuestions($cat egory_id)-1)?$questionCou nter+1:$questio nCounter;
//test 2
echo"\$question Counter: ".$questionCoun ter."<br>";
[color=blue]
>getNumberOfQue stions($categor y_id) correctly returns amount of[/color]
questions in db;[color=blue]
>values for $Submit is set;
>first call to $questionCounte r gives ""
>second call to $questionCounte r gives 0
>session.auto_s tart=1 in php.ini[/color]
$questionCounte r never adds up. Always when I call the page via the
'next page' button the initial value of $questionCounte r ="", after
the code it's 0
What's wrong - how can I make this work?
Thanks,
Marc
Comment