Jump to content


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


SOLVED: Passing a URL variable.

Recommended Posts

This problem has been solved. I used a SQL database instead. Thanks...




I am fairly new to php but I have been studying it intently.

My question has to do with pulling a global variable from the URL, and assigning that variable into the call-up for an array. Let me explain further...

I am setting up a collectors site for trading cards for a family member, and I want to call up a single php page and define a card number in the URL, like this... 



Then I want to read in that card=0001, and assign it's value to an array call-up, that will fetch the array associated with that card.

I am using a standard variables.php file, and simply importing it into the Detail.php page. I have got the variables to import, but so far I have had to specifically define the variable I am calling up. As such,




However doing it this way means that for the thousands of cards featured, there will need to be a seperate page for each. YUK! My goal is to actively change the number in "Card0001", based upon the URL. And simply have one page that adjusts the inputs based on the URL.

Now I've tried the following method, but so far I just can't make it work,



if (!isset($_GET['card'])) {
  $page = "card";
else {
  $page = $_GET['card'];


This code does what I want. It does get the value of "card" from the URL, because a simple print statement verifies it.

However after trying many ways to input the value of "card" into the array query I have been unable to associate the two. This was one way I have attemped to do it:




But of course this doesn't work...

Now, can this be done, or does anyone have any recommendations on how I can pass the value of the "card" from the URL, into the array call-up here?

Any help would be greatly appreciated. Thanks.


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.