Jump to content


Photo

SOLVED: Passing a URL variable.


  • Please log in to reply
No replies to this topic

#1 WebG0PHER

WebG0PHER
  • New Members
  • Pip
  • Newbie
  • 1 posts
  • LocationMaryland

Posted 26 September 2006 - 06:31 PM

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


Chris


 


Greetings,

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

http://somewebsite.com/detail.php?card=0001


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,


<?$CARD0001["title"];?>


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,


<?php
include("template.html");
include("variables.php");

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:


<?$CARD"$page"["title"];?>


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.



WebG0PHER




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users