Re: table.php

From: Date: Mon, 11 Oct 2004 22:07:23 +0000
Subject: Re: table.php
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-14858@lists.php.net to get a copy of this message
Erico Henrique Guimaraes wrote:
Dear sirs, Sorry for disturbing you but I could not find any example on how to do it. It´s simple: I have two files: tableA.php and tableB.php . I use PEAR HTML/Table.php to retrieve a table, queried from a database, just like the one below. ID EMPRESA CPF/CGC
12345	COMPANY B     234567890
12346	COMPANY A     34321567
12347	COMPANY C     234563789
snip
As you could note, one of the columns, namely EMPRESA, is a hyperlink, whose content is $row["cmpy_name"]. What I want to do is simply to click on the hyperlink and pass over from tableA.php the id number - $row['cmpy_id'] - of the hyperlinked company to another page, namely tableB.php in order to retrieve other information from the selected company by the user.
What it sounds like you want to do is to use the $_GET variable... as in... $url = 'http://example.com/companydetails.php?id=' . $row['cmpy_name']; Then in companydetails.php you get the id from the $_GET['id'] variable. Of course, there is the more than likely probability that someone will call the page without passing the ID. So put a check in there for that. I'd suggest using HTML_QuickForm as an appropriate way to input data about the company... but the way I understand it you only want to display more details, not provide an easy way to edit.
I don´t know whether this the best approach but I assume there are other ways to do so. Actually I could do some workaround to do so but I would like to write code in compliance to PEAR and its packages. Is there any package more suitable to it than table.php?
Hmm... HTML_Table is the basic framework you want to use for displaying tabular data or a table in HTML. As of now, it does not yet support XHTML strict. You may want to look at Structures_DataGrid for a simple way to sort and edit data from a database. hth, Klaus

« previous php.pear.general (#14858) next »