Parameter passing
Hi,
I am trying to understand the online polls example shown in the book PHP-MySQL Programming page 286. I guess it is related to the issue of parameter passing between a PHP script and a PHP class. There are 2 elements involved:
1 - ../polls/index.php, a script that calls the function getActivePolls($iCursor) from the class.polls.php to populate dynamically an array called $aPoll. The $iCursor variable is derived from a URL query and can take the value 0,1 or 2 via a $_GET["cursor"]. The array is defined as follows:
$aPoll = $oPolls->getActivePolls($iCursor);
2 - ../class.polls.php, an object class that includes, among others, the above function called getActivePolls(), with one argument $iPage, that retrieves a particular poll from a MySQL table, in the following way:
function getActivePolls($iPage=0) {
$sql = "SELECT poll_id,poll_vote_cnt,poll_question
FROM tab_polls
WHERE status=1 AND deleted =0
ORDER BY created_dt DESC
LIMIT ".$iPage.",1;
//...some more code to check DB error
}
My Problem:
I cannot get $iPage to vary dynamically in sync with $iCursor, so as to be able to paginate through all three different polls (for $iPage=0,then 1, then 2), as input for $iCursor itself is derived from a pagination form defined in ../polls/index.php.
Thanks in advance for a clue.
|