can php loops be continued throughout html

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

    #1

    can php loops be continued throughout html

    I'm redoing some ASP pages into php, asp pages have things like:

    A loop if something then

    //show some html code

    another loop, if something

    //show some more code.

    Can this be done in php?

    so that i could do:

    <?php
    If $_SESSION['logon'] == "true" Then {
    ?>
    <table border="0" cellpadding="0" cellspacing="0" width="100%" ...

    and so forth?

    Cheers

  • James McIninch

    #2
    Re: can php loops be continued throughout html

    Certainly.

    <?php for ($i=0; $i<100; ++$i) { ?>
    value of $i is <i><?=$i?></i>.
    <?php } ?>

    Advo wrote:
    I'm redoing some ASP pages into php, asp pages have things like:
    >
    A loop if something then
    >
    //show some html code
    >
    another loop, if something
    >
    //show some more code.
    >
    Can this be done in php?
    >
    so that i could do:
    >
    <?php
    If $_SESSION['logon'] == "true" Then {
    ?>
    <table border="0" cellpadding="0" cellspacing="0" width="100%" ...
    >
    and so forth?
    >
    Cheers

    Comment

    • Peter Fox

      #3
      Re: can php loops be continued throughout html

      Following on from James McIninch's message. . .
      >Certainly.
      >
      ><?php for ($i=0; $i<100; ++$i) { ?>
      >value of $i is <i><?=$i?></i>.
      ><?php } ?>
      or

      <?php
      for ($i=0; $i<100; ++$i) {
      print("<td><fon t color=red>$i</font></td>\n");
      }
      ?>

      <?php
      for ($i=0; $i<100; ++$i) {
      $s = vsprintf('%3d </font%4.2f",arra y($i,$i/7));
      print("<td><fon t color=red>$s</td>\n");
      }
      ?>


      --
      PETER FOX Not the same since the submarine business went under
      peterfox@eminen t.demon.co.uk.n ot.this.bit.no. html
      2 Tees Close, Witham, Essex.
      Gravity beer in Essex <http://www.eminent.dem on.co.uk>

      Comment

      • Tim Roberts

        #4
        Re: can php loops be continued throughout html

        Peter Fox <peterfox@emine nt.demon.co.uk. not.this.bit.no .htmlwrote:
        >
        >Following on from James McIninch's message. . .
        >>Certainly.
        >>
        >><?php for ($i=0; $i<100; ++$i) { ?>
        >>value of $i is <i><?=$i?></i>.
        >><?php } ?>
        >
        >or
        >
        ><?php
        for ($i=0; $i<100; ++$i) {
        print("<td><fon t color=red>$i</font></td>\n");
        >}
        >?>
        >
        ><?php
        for ($i=0; $i<100; ++$i) {
        $s = vsprintf('%3d </font%4.2f",arra y($i,$i/7));
        print("<td><fon t color=red>$s</td>\n");
        >}
        >?>
        I've never understood the aversion to the <?= construct in PHP. One of the
        appeals of PHP is that I can write full PHP modules for the processing, and
        HTML with <?= escapes for the presentation side. It's like having a
        built-in templating engine.

        If I have to write everything out in PHP code, I might as well use a more
        sopisticated language.
        --
        - Tim Roberts, timr@probo.com
        Providenza & Boekelheide, Inc.

        Comment

        • Jerry Stuckle

          #5
          Re: can php loops be continued throughout html

          Tim Roberts wrote:
          Peter Fox <peterfox@emine nt.demon.co.uk. not.this.bit.no .htmlwrote:
          >
          >>Following on from James McIninch's message. . .
          >>
          >>>Certainly.
          >>>
          >>><?php for ($i=0; $i<100; ++$i) { ?>
          >>>value of $i is <i><?=$i?></i>.
          >>><?php } ?>
          >>
          >>or
          >>
          >><?php
          > for ($i=0; $i<100; ++$i) {
          > print("<td><fon t color=red>$i</font></td>\n");
          >>}
          >>?>
          >>
          >><?php
          > for ($i=0; $i<100; ++$i) {
          > $s = vsprintf('%3d </font%4.2f",arra y($i,$i/7));
          > print("<td><fon t color=red>$s</td>\n");
          >>}
          >>?>
          >
          >
          I've never understood the aversion to the <?= construct in PHP. One of the
          appeals of PHP is that I can write full PHP modules for the processing, and
          HTML with <?= escapes for the presentation side. It's like having a
          built-in templating engine.
          >
          If I have to write everything out in PHP code, I might as well use a more
          sopisticated language.
          Because it requires short tags to be enabled, which can conflict with
          other languages. For instance, xml uses <?xml to indicate an xml block.
          And with short tags on, this would be detected as the start of a PHP
          statement.

          It's why most systems run with short tags disabled.


          --
          =============== ===
          Remove the "x" from my email address
          Jerry Stuckle
          JDS Computer Training Corp.
          jstucklex@attgl obal.net
          =============== ===

          Comment

          • Tim Roberts

            #6
            Re: can php loops be continued throughout html

            Jerry Stuckle <jstucklex@attg lobal.netwrote:
            >Tim Roberts wrote:
            >>
            >I've never understood the aversion to the <?= construct in PHP. One of the
            >appeals of PHP is that I can write full PHP modules for the processing, and
            >HTML with <?= escapes for the presentation side. It's like having a
            >built-in templating engine.
            >>
            >If I have to write everything out in PHP code, I might as well use a more
            >sopisticated language.
            >
            >Because it requires short tags to be enabled, which can conflict with
            >other languages. For instance, xml uses <?xml to indicate an xml block.
            And with short tags on, this would be detected as the start of a PHP
            >statement.
            >
            >It's why most systems run with short tags disabled.
            Duh, yes, I ranted about the wrong thing. I see that even my own server is
            configured with short tags turned off.

            I intended to rant about the ASP-style tags ( <%= ) which are, I believe,
            usually enabled. But, somehow, the argument loses some of its impact when
            its made a second time...
            --
            - Tim Roberts, timr@probo.com
            Providenza & Boekelheide, Inc.

            Comment

            • Jerry Stuckle

              #7
              Re: can php loops be continued throughout html

              Tim Roberts wrote:
              Jerry Stuckle <jstucklex@attg lobal.netwrote:
              >
              >>Tim Roberts wrote:
              >>
              >>>I've never understood the aversion to the <?= construct in PHP. One of the
              >>>appeals of PHP is that I can write full PHP modules for the processing, and
              >>>HTML with <?= escapes for the presentation side. It's like having a
              >>>built-in templating engine.
              >>>
              >>>If I have to write everything out in PHP code, I might as well use a more
              >>>sopisticat ed language.
              >>
              >>Because it requires short tags to be enabled, which can conflict with
              >>other languages. For instance, xml uses <?xml to indicate an xml block.
              >And with short tags on, this would be detected as the start of a PHP
              >>statement.
              >>
              >>It's why most systems run with short tags disabled.
              >
              >
              Duh, yes, I ranted about the wrong thing. I see that even my own server is
              configured with short tags turned off.
              >
              I intended to rant about the ASP-style tags ( <%= ) which are, I believe,
              usually enabled. But, somehow, the argument loses some of its impact when
              its made a second time...
              Actually, I think ASP-style tags are generally disabled also. At least
              they are on my servers and most of the shared hosts I've used.


              --
              =============== ===
              Remove the "x" from my email address
              Jerry Stuckle
              JDS Computer Training Corp.
              jstucklex@attgl obal.net
              =============== ===

              Comment

              Working...