How do you pass the results array of a MySQL query between pages?

Thanks

Artoo

    If you are calling for the variables on one page, then clicking "next" or something to go to another page, then:

    You will need to use sessions or pass the variables in the URL.

      Here is a little bit I just wrote, untested of course. Hope it helps.

      HOME

      <?php
      $var = array(1,5,9);
      
      //set sessions and go to the next page
      foreach($var as $key=>$val){
      	$_SESSION[$val];
      }
      echo "<a href=\"next.php'>Next</a>";
      
      //this part if for the URL array
      echo "<a href=\"next.php?";
      foreach($var as $key=>$val){
      	echo $key."=".$val;
      }
      echo ">Next</a>";
      ?>

      NEXT.PHP

      <?php
      //get out session array
      while(list($key, $val) = each($_SESSION)){
      	echo $val."<br />";
      }
      
      //this part is for getting them from the URL
      while(list($val) = each($_GET)){
      	echo $val."<br />";
      }
      ?>
      

        so I have to take the MySQL result array and place it into a session variable like the code below?

        $result = mysql_query($sql);
        while ($fetch[] = mysql_fetch_array($result)));
        $_SESSION['results'] = $fetch;
        

          Yeah, accept I think you have one too many )'s on your while statement.

            Write a Reply...