Table columns as hyperlink

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
markniazi
Forum Newbie
Posts: 3
Joined: Mon Nov 14, 2011 9:46 am

Table columns as hyperlink

Post by markniazi »

I am new to PHP and working on a PHP - MYSQL project. The problem I am facing is described below, kindly guide me about it.

I have a table with two columns "Name" and "Type". I take input from user using a text box and return all the values matching "Name" column of the table.

The results are shown in an html table in which each row holds two values i.e. "Name" and "Type" returned from table using MYSQL query.

Now i want a way in which text showed in first column i.e. "Name" becomes a hyperlink and on clicking it takes to a new page displaying "Name" & "Type" which was clicked.

Thanks
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Table columns as hyperlink

Post by Celauran »

Perhaps the easiest way to do this is to create a page to display individual records and pass the desired name via GET (ie. somepage.php?name=$name).
User avatar
manohoo
Forum Contributor
Posts: 201
Joined: Wed Dec 23, 2009 12:28 pm

Re: Table columns as hyperlink

Post by manohoo »

Assuming the target is details.php:

Code: Select all

$query = "
   SELECT concat('<a href=details.php?name=',name,'&type=',type,'>',name,'</a>') as link
   FROM table
";
Post Reply