Passing variables from a link?
Posted 05 April 2006 - 03:40 AM
In an attempt to begin learning PHP I undertook the development of a stats processor for W:ET. I realize there are many out there, but I needed something I could use in order to challenge myself. I'm using Python to parse the server log and populate my MySQL database.
I'm attempting to use PHP to access the info from the database and display it.
(Think that's enough useless background for now...)
Anyway, let's say my first page consists of all the players and general stats, like kills and deaths. What I want is each player name to be hyperlinked so you could view specific stats for that particular player. So I'll have a playerProfile.php page that access all valid info for specified player, and display it, all it needs to know is which player to grab all valid data for. So each player link should link to playerProfile.php, and say "I'm player <player>"
I'd really just like to know what this process is referred to so I know what to search for. Where I stand right now...well, I'm clueless.
So if anybody could just give me some things to search for I'd really appreciate it.
Posted 05 April 2006 - 03:54 AM
anyhow, what you're looking for are URL variables, formally known as sending a GET request. when you construct a link like so:
then on the receiving page, a GET request has been sent with the info specified in the URL. this information is stored in the superglobal (just meaning accessible anywhere in a script) $_GET, which for all intents and purposes acts exactly like a regular array. in this case, the value "value" is accessible in:
it sounds like what you are looking for is simply a link that sends the player's ID. i reckon echoing a link like so in your table (or however you're displaying the players) will work:
<a href="playerProfile.php?player_id=$idhere">Player Name</a>
then on playerProfile.php, your player's ID is stored in $_GET['player_id'] and can be used accordingly in a query to grab his stats.
any number of variables can be appended to the request and sent to the $_GET array by using & between variables, like so:
hope this helps.
Posted 05 April 2006 - 04:02 AM
It's frustrating not knowing what to look for when you wanna do something.
Again, thanks a lot.
Posted 05 April 2006 - 04:19 AM
Now, if only I had the parsing part done for all the specific stats.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users