Page 1 of 1
Going from generated table to detail page
Posted: Thu Jun 14, 2007 11:06 am
by ReverendDexter
I'm working on a page that has a generated table of items coming from a MySQL database. This table doesn't have all of the fields pertinent to each item (for space reasons), so I'd like to set up some way for a user to click on the row, and have them go a page that does have all of the information.
What I'm wondering is what's the best practice for accomplishing this? I don't want code, just to be pointed in the right direction

My idea is to somehow have the page with the list [somehow] send the item id, and then the receiving page can just do the query/display off all the data [the easy part]. My problem is I'm next to totally clueless as to get the id from the sending page. I know that I don't want it to be a radio-button/submit setup; I'd like it to just look and act like a link. Can I send something along with an href? That would certainly make my life easier...
My apologies if this was rambling, incoherent, or in the wrong section.
-Dex
Posted: Thu Jun 14, 2007 11:56 am
by RobertGonzalez
What you are talking about is called a drill-down, where you present a subset of data that, when presented, offers the user the ability to see more when they click a link.
The basics of this is to present a list of links which have an id in the querystring of some sort, then when the user clicks the link, the page that the link points to checks for the presence of the $_GET value and uses that in the query to select just that row from the database. Once you have it, show it.
PS This is being moved to PHP - Code as it is really not a Theory and Design question so much as a How-To question. And welcome to the boards!
Posted: Thu Jun 14, 2007 1:30 pm
by Weirdan
you can pass values in url like this:
http://something.com/something.php?somevar=somevalue and then access them in the php file (somthing.php in this case) like this:
Code: Select all
echo $_GET['somevar']; // would echo 'somevalue'
Posted: Thu Jun 14, 2007 3:41 pm
by Christopher
There are also a couple of different ways to solve this drill-down problem -- once you have sorted out passing request variables. You can go to a new page in the same window, you can popup a new window with the detail, or you can use Ajax to load the detail and expand a <div> to display in right in the current page.
Posted: Thu Jun 14, 2007 5:44 pm
by Luke
The easiest way at the moment would probably be just to go to a detail page... let's not get overly complicated just yet.