Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Sep 2006
    Posts
    72
    Thanks
    3
    Thanked 0 Times in 0 Posts

    very newbie class Q?

    I have moderate PHP but have never used classes.

    Looking at an html table builder:
    http://www.phpbuilder.com/snippet/de...=snippet&id=58

    with various classes and functions.

    I am really not sure how to get this thing running.

    Any refs to tutorials or such OR anyone who has time to look at this code.
    I am aiming to add a table builder to a WYSWIG CMS.

    Any other table builders - really want one with rowspan and colspan functionality.

    Thanks

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    This is ancient code. Don't use it as it comes from 4.x generation of PHP.

    To use it though, you would do as so:
    PHP Code:
    $a = array(
        
    'rows' => 2,
        
    'cols' => 1,
        
    'content' => 'cat'
    );

    $table = &new html_table();
    $table->init($a);
    $table->display(); 
    Best I can tell there is no way to separate the data into individual rows and columns. Every method that sets the cell data calls the cell_init function which simply returns some data including $this->cell_content. This member property is scalar, so you can only fill a table with a specific data; there is no method to change the data in a specific cell.
    To do this, you need to modify the member directly (which is a no-no in PHP5):
    PHP Code:
    $table = &new html_table();
    $table->init(array('rows' => 2'cols' => 1));
    $table->cell[1][1]['content'] = 'cat';
    $table->cell[2][1]['content'] = 'dog';
    $table->display(); 
    So short of it, don't even consider using this code.

  • #3
    New Coder
    Join Date
    Sep 2006
    Posts
    72
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thanks for taking the trouble to look at that.
    And a canuck :]

    Dang it all tho'. I thought it may have been the answer.
    There are lots of online table builders but none with row-col merging.

    I will keep looking.

    Thanks again.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •