array problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • coolv
    New Member
    • Jan 2008
    • 6

    #1

    array problem

    Hello Everyone

    this is my code

    $snoopy = new Snoopy();
    $links=$_SESSIO N['links']; //Array of links

    for(int $i=0;$i<count($ links);$i++)
    {
    $snoopy->fetchlinks($li nk);
    $links1=$snoopy->results;
    $_SESSION['links1']=$links1;
    echo '<script language="javas cript">document .location="'.ba sename ($_SERVER['PHP_SELF']).'";</script>'; //Reload the page
    }

    Here $link is array of links. first time for loop is executed it takes first link for bellow code.after that page is reloaded. here i want after page reload for loop is start with incaremented value of i.

    also i want to know how to access array values in for loop after or befor pageload.

    Can anyone has solution for this.

    thanks in advance
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    Here $link is array of links. first time for loop is executed it takes first link for bellow code.after that page is reloaded. here i want after page reload for loop is start with incaremented value of i.
    You need to keep a tally in the script but outside the loop $val++; and pass the current value of val via a URL variable.
    Place this after [PHP]$_SERVER['PHP_SELF'].'?val='.$val;[/PHP] There are more sophisticated ways ie SESSION variables.

    Comment

    Working...