Thread: Looping code

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    1
    Rep Power
    0

    Looping code


    is there a way to loop html code when making a table?
    here is my code and what im trying to do
    PHP Code:
    <TR>
            <
    TD WIDTH="10%">
                <
    DIV ALIGN="CENTER">
                    <
    P><B><FONT FACE="Verdana, Arial, Helvetica, sans-serif">1</FONT></B>
                </
    DIV>
            </
    TD>
            <
    TD WIDTH="8%">
                <
    CENTER>
                <
    P><INPUT TYPE="TEXT" NAME="start1" SIZE="7" VALUE="0">
    </
    CENTER>
            </
    TD>
            <
    TD WIDTH="8%">
                <
    CENTER>
                <
    P><INPUT TYPE="TEXT" NAME="stop1" SIZE="7" VALUE="0">
    </
    CENTER>
            </
    TD>
            <
    TD WIDTH="21%">&nbsp;</TD>
            <
    TD WIDTH="24%">&nbsp;</TD>
            <
    TD WIDTH="29%">
                <
    CENTER>
                <
    P><INPUT TYPE="TEXT" NAME="personal1" SIZE="9" VALUE="0">
    </
    CENTER>
            </
    TD>
        </
    TR
    i want this block looped but at the same time i want each previous loop to add 1 to values such as the "1" and "start1","stop1" ect ect. I know the basics of html but really want to get this to work. thanks for any help!
  2. #2
  3. Code Monkey V. 0.9
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2005
    Location
    A Land Down Under
    Posts
    2,111
    Rep Power
    1990
    Using HTML, no. HTML is not a programming language, and doesn't have any sort of flow control like loops, if/else, etc.

    To do a loop you need to use a server-side language to output the HTML code that you want. This can be whatever you have available, but is mostly going to be something like PHP, ASP, Python, etc.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    11
    Rep Power
    0
    ok thank you for clearing that up Catacaustic
  6. #4
  7. No Profile Picture
    buildmyweb.org
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Location
    NY
    Posts
    65
    Rep Power
    8

    Post


    you could also use client-side like javascript if you are more comfortable there. i prefer php myself. something as simple as

    Code:
    <?php 
    for( $i=0; $i < 10; $i++ )
    {
    ?>
    
    ...<P><INPUT TYPE="TEXT" NAME="stop<?php echo $i; ?>" SIZE="7" VALUE="0"> 
    
    <?php } ?>

IMN logo majestic logo threadwatch logo seochat tools logo