maintaining continuous count in php
- by LiveEn
I have a small problem maintain a count for the position. i have written a function function that will select all the users within a page and positions them in the order.
Eg:
Mike Position 1
Steve Postion 2..............
....
Jacob Position 30
but the problem that i have when i move to the second page, the count is started from first
Eg: Jenny should be number 31 but the list goes,
Jenny Position 1 
Tanya Position 2.......
Below is my function
function nrk($duty,$page,$position)
{
    $url="http://www.test.com/people.php?q=$duty&start=$page";
    $ch=curl_init();
    curl_setopt($ch,CURLOPT_URL,$url);
    $result=curl_exec($ch);
        $dom = new DOMDocument();
        @$dom->loadHTML($result);
        $xpath=new DOMXPath($dom);
        $elements = $xpath->evaluate("//div");
        foreach ($elements as $element)
        {
            $name  = $element->getElementsByTagName("name")->item(0)->nodeValue;
            $position=$position+1;
            echo $name." Position:".$position."<br>";
        }   
            return $position;
    }
Below is the for loop where i try to loop thru the page count
for ($page=0;$page<=$pageNumb;$page=$page + 10)
        {
            nrk($duty,$page,$position);
        }
I dont want to maintain a array key value in the for each coz i drop certain names...