problem calculating the position using php

Posted by LiveEn on Stack Overflow See other posts from Stack Overflow or by LiveEn
Published on 2010-03-19T12:21:13Z Indexed on 2010/03/19 12:31 UTC
Read the original article Hit count: 172

Filed under:

I have a function below which gets name from a site. Below is the partial code, not complete. The values are passed thru a for loop using php.

function funct($$name,$page)

    {
        $url="http://testserver.com/client?list=$name&page=$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;
            }   
        }

The code works fine but when i get a name i need to add a position and for each name it will be incremented by 1 to make it contentious. But when the values for the pages are passed, for an example when i move from page 1 to page 2. the count starts again from first, next page... same problem.

How can i make it continues on every page?

© Stack Overflow or respective owner

Related posts about php