Page 1 of 1

Table columns as hyperlink

Posted: Mon Nov 14, 2011 10:03 am
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

Re: Table columns as hyperlink

Posted: Mon Nov 14, 2011 10:35 am
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).

Re: Table columns as hyperlink

Posted: Mon Nov 14, 2011 5:46 pm
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
";