Announcement

Collapse
No announcement yet.

template question for the pros

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • template question for the pros

    on working for the poll hack, I got stuck on this:

    In order to let the user define the number of options, I use 2 templates:

    newpoll:
    <smallfont>Remember to keep the poll options short and to the point</smallfont>

    <BR>

    <TABLE WIDTH="100%" CELLPADING="0" CELLSPACING="2" BGCOLOR="#FFFFFF">

    $pollnewbit

    </TABLE>
    and newpollbit:

    <TR>
    <TD><normalfont>Option $run:</normalfont></TD>
    <TD><INPUT NAME="Option$run" TYPE="TEXT" sIZE="45"></TD>
    </TR>
    Now, I want to call newpoll once and newpollbit x times. The following code however, only gives me once newpollbit:

    for ($run=1; $run < $PollNum; ++$run){
    eval("\$pollnewbit = \"".gettemplate("pollnewbit")."\";");
    }
    eval("\$pollnew = \"".gettemplate("pollnew")."\";");
    What am I doing wrong? Probably something stupid

  • #2
    Actually in PHP
    Code:
     ++$a
    is the same as
    Code:
     $a++
    Interested in Linux?
    Have a question?
    http://www.linuxquestions.org

    Comment


    • #3
      Almost forgot... There IS a difference between the two - just not in the context that was asked.
      Code:
      $a = 10;       // $a is 10
      $b = $a++;     // $a is 11, but $b is 10 (The assignment occued before the incrementation)
      but
      Code:
      $a = 10;       // $a is 10
      $b = ++$a;     // $a and $b are both 11 (The assignment occured after the incrementation
      Interested in Linux?
      Have a question?
      http://www.linuxquestions.org

      Comment


      • #4
        I solved it myself. should be

        for ($run=1; $run < $PollNum; $run++){
        eval("\$pollnewbit .= \"".gettemplate("pollnewbit")."\";");
        }
        anyone know the full meaning of .= in comparison to just a = in templates?

        Comment


        • #5
          .= appends while = does not. For example:
          Code:
          $a = "hello ";
          $a = "world";  // $a is world
          while
          Code:
          $a = "hello ";
          $a .= "world"; // $a is hello world
          Interested in Linux?
          Have a question?
          http://www.linuxquestions.org

          Comment


          • #6
            .= seems to be the equivalent to += in C. I need to look up why they felt the need to use a . to denote addition.

            Comment


            • #7
              ?? what is template in vb ??

              sorry for my stupid question , but idon'n know and really would like to khow about vb template.
              what is and wheeis vb template?
              thanks

              Comment


              • #8
                a template defines how the page looks like. this means you can alter the look without hacking at the codebase.

                Comment

                widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                Working...
                X