Jump to content

Archived

This topic is now archived and is closed to further replies.

monkeymax

Populating array on page reload

Recommended Posts

I've been unsucessfully trying to get this to work for the last hour so I thought I would turn to the experts!

The situation is that I have a page of matches that I would like the user to select from. Say the page is called "matches.php". The table would look like:

Match 1 Dog vs Cat
Match 2 Praying Mantis vs Butterfly
....

The match players are links, and the match number and player id are passed back to the page, so Dog would be linked as:
<a href="matches.php?match=1&amp;player="Dog">Dog</a>

Now my problem is when the page is reloaded, I want these details to be stored in an array. I thought it would be as simple as:

if(!isset($_GET['match'])){
$match_array=array();
}

else{
$match_array[$_GET['match']] = $GET['player'];
}

Which would be working perfectly [b]except[/b] for the fact that the array gets reloaded everytime I load the page, so it only ever has one entry. I would like it to store all previous match data. I don't have much experience with static and global variables and was hoping someone would be able to suggeset a solution for this,

Thanks!

Share this post


Link to post
Share on other sites
Pass the array with sessions, simplest solution I can think of.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.