Passing arrays trough pages!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
pedrokas
Forum Commoner
Posts: 32
Joined: Thu Jan 15, 2004 10:53 am
Location: Lisboa, Portugal

Passing arrays trough pages!

Post by pedrokas »

Hi again
i tried to pass an array trought pages, and the only solutions i get (not mutch time to think) was passing the values as parameters.
I think, and hope, there are a better and cleaner way to do it, and my question to you all is ...HOW?

$myrec[number] = field from a table;
$arrystr = my array, in this case only 4 rows;
$nor_arrystr = number of rows of the array; // 4

Code: Select all

<? 
(...)
echo ($novotit."<a href = "nextpage.php?$numnot=$myrec&#1111;number]"); forech($arrystr as $k =>$n)
&#123;
  echo("&val$k=$n");
&#125;
echo("&tot=".$nor_arrystr."">ver</a>");
(...)
?>
in the nextpage.php ...

Code: Select all

<?
$array_loc = array();
$nor_array = $_GET&#1111;'tot'];
for($i = 0; $ <= $nor_array; $i++)
&#123;
  array_push($array_loc, $_GET&#1111;'val'.$i]);
&#125;
?>
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

http://www.php.net/session

this way you don't have to copy the data back-and-forth between server and client either....
Post Reply