Jump to content

Populating array on page reload


monkeymax

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!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.