469,902 Members | 1,815 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,902 developers. It's quick & easy.

PEAR::HTML_Table question: link in cell

Hi to everyone,

I'm relatively new to php and to PEAR in particular.

I'm using PEAR, especially the HTML_Table package. It's almost clear
how the things work, but I've a question for which I'll appreciate
your opinions.

I fetch some record from a MySQL db and print them out on a table with
addRow() method: no problem until here.
But how I can do the same if I want to put a link in some cells.
For example, I want soomething like this:

| 1 | apple | 2,90 | available |
| 2 | pear | 1,90 | available |
| 3 | orange | 3,00 |not available |

and I want that apple, pear and orange are link to other pages, that
is, I want to put an "<a href="..."> tag in the second colum of the
table

| 1 |<a href="..."> apple</a> | 2,90 | available |
| 2 | <a href="...">pear</a> | 1,90 | available |
| 3 |<a href="..."> orange </a>| 3,00 | not available |

I think I should could use setCellValue(), but can you help me to find
an "elegant" and efficient solution?

I do not ask for the code, only some hint (however, some pieces of
code will be appreciated :-) )

Hoping someone could help me, thanks in advance.

Bye
Robbie

Jul 17 '05 #1
1 2147
Robbie wrote:
I think I should could use setCellValue(), but can you help me to find
an "elegant" and efficient solution?

I do not ask for the code, only some hint (however, some pieces of
code will be appreciated :-) )

Hoping someone could help me, thanks in advance.


Well, addRow() takes an array of arguments as the first value, so you
do something like this:

....
$_row = array ("<a href=\"foobar.html\">foobar</a>",
"12.95USD",
"available");
$table->addRow($_row);
....

HTML_Table doesn't care what the data in the cells is. Ofcourse you can
set the value later, but the cell must exist for you to do that.

/Marcin
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by me | last post: by
8 posts views Thread by red | last post: by
reply views Thread by Chris | last post: by
1 post views Thread by DJ Majestik | last post: by
3 posts views Thread by Mladen Gogala | last post: by
3 posts views Thread by bob.herbst | last post: by
1 post views Thread by Julien Sobrier | last post: by
3 posts views Thread by Mladen Gogala | last post: by
1 post views Thread by IchBin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.