layout function

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

    layout function

    Hi there,

    i want to build a function to create layout parts.
    It has to create tables.

    What i want now is to have the following function:
    function doTable($state, $width, $height);
    {
    echo ($state === 1)? '<table width="'.$width .'"
    height="'.$heig ht.'"><tr><td>' : '</td></tr></table>'

    };
    (extremely simlified)

    And call it this way:

    doTable(1, 350, 400);

    echo 'table content';

    doTable(0);

    Can/How do i handle the 'missing variables' in the second 'doTable()'?

    Thanks in advance!

    Greetings Frizzle.

  • Janwillem Borleffs

    #2
    Re: layout function

    frizzle wrote:[color=blue]
    > Can/How do i handle the 'missing variables' in the second 'doTable()'?
    >[/color]

    function doTable($state, $width = 0, $height = 0)


    JW



    Comment

    • frizzle

      #3
      Re: layout function

      If i'm not mistaking, do i implement
      the following in the function:

      echo ($width != 0)? 'width is set' : 'width isn't set';

      Greetings Frizzle.

      Comment

      • Janwillem Borleffs

        #4
        Re: layout function

        frizzle wrote:[color=blue]
        > If i'm not mistaking, do i implement
        > the following in the function:
        >
        > echo ($width != 0)? 'width is set' : 'width isn't set';
        >[/color]

        Yep. Alternatively, you can just make the $state argument leading; when it's
        0 close the table, ignoring the $width and $height arguments and open a new
        table otherwise.


        JW



        Comment

        • frizzle

          #5
          Re: layout function

          what do you mean with making the $state argument leading?
          Indeed, it's meant to close the table when $state === 0, but i
          don't quite understand your last answer.
          Thanks for helping by the way!!!!!

          Greetings Frizzle.

          Comment

          • Marcin Dobrucki

            #6
            Re: layout function

            frizzle wrote:[color=blue]
            > i want to build a function to create layout parts.
            > It has to create tables.[/color]

            How about looking at HTML_Table from PEAR? It will generate tables
            for you, and you can pass arguments for height, etc. Its a life saver
            after you try to modify your table layout later.

            /Marcin

            Comment

            • Janwillem Borleffs

              #7
              Re: layout function

              frizzle wrote:[color=blue]
              > what do you mean with making the $state argument leading?
              > Indeed, it's meant to close the table when $state === 0, but i
              > don't quite understand your last answer.
              > Thanks for helping by the way!!!!!
              >[/color]

              function whatever($state , $w = 0, $h = 0) {
              if ($state == 0) {
              // Close and full stop, don't care about
              // the values of $w & $h
              } else {
              // Do something with $w & $h
              }
              }


              JW



              Comment

              Working...