I am fairly new to php and I am having some difficulty passing variables between pages using hyperlinks.
Im using a table to generate a list of items pulled from a database and hyperlinks to link the items to a second php page. This is the code I am using…
<td><a href="item.php?item=' . $row['ItemID'] . '">' . $row['ItemName'] . '</a></td>
This all seems to work fine until I get to the second page where I am unable to use the variable.
Is there any code that I need to include on the second page to retrieve the variable? So far I have been using $item which doesn’t seem to work.
Passing variables between pages with php
Moderator: General Moderators
-
pfairclough
- Forum Newbie
- Posts: 2
- Joined: Mon Mar 15, 2004 6:30 am
- Location: UK
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
If on the second page you are trying to do this:
then you need to change the way you are trying to access the query string variable to:
Mac
Code: Select all
echo 'the value of item in the URL query string is: '.$item;Code: Select all
echo 'the value of item in the URL query string is: '.$_GET['item'];-
pfairclough
- Forum Newbie
- Posts: 2
- Joined: Mon Mar 15, 2004 6:30 am
- Location: UK