Results 1 to 7 of 7

Thread: PHP while Loop

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2005
    Posts
    46,704

    Default PHP while Loop

    The while loop executes a block of code while a condition is true.


    Code:
    <html>
    <body>
    
    <?php
    $i=1;
    While($i<=5)
    {
    echo "The number is" . $i . "<br />";
    $i++;
    }
    
    ?>
    
    </body>
    </html>

    Out Put:

    The number is1
    The number is2
    The number is3
    The number is4
    The number is5




    Loop that starts with i=1. The loop will continue to run as long as i is less than, or equal to 5. i will increase by 1 each time the loop runs:
    Last edited by minisoji; 10-24-2011 at 07:07 AM.

Bookmarks

Posting Permissions

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