Connecting Tech Pros Worldwide Help | Site Map

a href tag and PHP session

imarkdesigns's Avatar
Member
 
Join Date: Jul 2007
Location: Philippines
Posts: 37
#1: Jan 4 '09
good day,
i have this problem for awhile now and still can't find the answer (wish me luck here right now).

The concept is to have an anchor link with a value from MYSQL then pulling it out to put it in another page.

here is my code: (sorry about the code, im begging to the expert, just a newbie here).

Expand|Select|Wrap|Line Numbers
  1. <li>&raquo; <a href="listings.php"><?=$rows['title'];?></a> - <?=$rows['city'];?>, <?=$rows['state'];?></li>
  2.  
once the title link hits, the value will get and post it to "listings page". code will be like this...
Search page
Expand|Select|Wrap|Line Numbers
  1. <a href="listings.php">List Category 1</a> - City, State
  2.  
this will be the outcome instead of the code is correct
Listings page
Title: List Category 1
City: City
State: State

**i used to try the PHP session but i seems the last table of MYSQL is always be visible and not the selected category which category has 10 list of it. Hope some one can help me here.. thanks in advance.
imarkdesigns's Avatar
Member
 
Join Date: Jul 2007
Location: Philippines
Posts: 37
#2: Jan 4 '09

re: a href tag and PHP session


ok, finally... got the answer.. thanks for viewing... haha
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,745
#3: Jan 4 '09

re: a href tag and PHP session


Hi.

Not entirely sure I get what you are saying, but. It seems you only need to pass a value via the link to the next page.

If so, you can simply add the value to the link, and then fetch it via the $_GET super-global.

That is, if your link looks like so:
Expand|Select|Wrap|Line Numbers
  1. <a href="page.php?item=someItem">Some item</a>
And your "page.php" page looked like so:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. echo $_GET['item'];
  3. ?>
Once you clicked that link, the "page.php" would print: "someItem".
Reply