PEAR::HTML_Table question: link in cell

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Robbie

    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

  • Marcin Dobrucki

    #2
    Re: PEAR::HTML_Tabl e question: link in cell

    Robbie wrote:
    [color=blue]
    > 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.[/color]

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

    ....
    $_row = array ("<a href=\"foobar.h tml\">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

    Comment

    Working...