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
https://forums.phpfreaks.com/topic/4664-populating-array-on-page-reload/
Share on other sites

Archived

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

×
×
  • 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.