Going from generated table to detail page

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
User avatar
ReverendDexter
Forum Contributor
Posts: 193
Joined: Tue May 29, 2007 1:26 pm
Location: Chico, CA

Going from generated table to detail page

Post 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
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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!
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post 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'
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post 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.
(#10850)
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post 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.
Post Reply