Date: 09/04/00
- Next message: Josh Udall: "Re: [phplib] destroy session"
- Previous message: Matthew Leingang: "[phplib] Re: PHPLIB and ooforms.inc"
- Next in thread: Jens Benecke: "[phplib] Extension of table class"
- Maybe reply: Jens Benecke: "[phplib] Extension of table class"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,
for a database project I did some extensions to the table() class. Perhaps
there is enough interest to clean them up a little and put them into the
main phplib tree.
Hyperlinks in table cells
~~~~~~~~~~~~~~~~~~~~~~~~~
First, table_cell is rewritten to allow hyperlinks to another document,
appending the current column name and the current value as parameters. For
example, in a column called "ID" a table cell would not look like
523a
but like
<a href="details.php?ID=523a">523a</a>
if the array $make_links contained an ID element with the value
"details.php".
This is the replacement method:
---------------------------------------------------------------------------
class MyTable extends Table {
# var $map_links = array();
function table_cell($row, $col, $key, $val, $class="") {
$this->table_cell_open($class);
if(isset($this->make_links[$key])) {
# Es gibt schon einen Parameter an der URL dran -> "?"->"&"
if(ereg("\?", $this->make_links[$key])) {
$c = "&";
} else {
$c = "?";
}
printf("<a href=\"%s\">%s</a>",
$this->make_links[$key].$c.$key."=".$val, $val);
} else {
printf("%s", $val);
}
$this->table_cell_close($class);
}
---------------------------------------------------------------------------
New method for labeling the checkboxes that are optionally placed in the
first column of a table row. I did this because I needed to know the
(database) ID of the table row, not the number of the shown table row. So I
set the counting element in "<input type=checkbox>" to something more
sensible: The current value of the table column whose name is in
$col_count. (which would ideally be a number or some sort of short ID.)
This enables me to put a submit button that "filters" selected table rows
out of the lot.
---------------------------------------------------------------------------
function table_checkbox_cell($row, $row_key, $data, $class="") {
if(isset($this->col_count)) {
$x = $data[$this->col_count];
} else {
$x = $row;
}
if ($this->check) {
printf(" <td%s><input type=\"checkbox\" name=\"%s[%s]\" value=\"%s\"></td>\n",
$class?" class=$class":"",
$this->check,
empty($data[$this->check])?$row_key:$data[$this->check],
$x);
}
}
---------------------------------------------------------------------------
Suggestions welcome, as always... ;)
-- `Q: Why did they deprecate a.out support in linux? http://www.linuxfaq.de A: Because a nasty coff is bad for your ELF.' http://www.hitchhikers.de --- James Simmons http://www.pinguin.conetix.de
- application/pgp-signature attachment: stored
- Next message: Josh Udall: "Re: [phplib] destroy session"
- Previous message: Matthew Leingang: "[phplib] Re: PHPLIB and ooforms.inc"
- Next in thread: Jens Benecke: "[phplib] Extension of table class"
- Maybe reply: Jens Benecke: "[phplib] Extension of table class"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

