Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Oct 2011
    Posts
    113
    Thanks
    9
    Thanked 1 Time in 1 Post

    WHILE lOOP limit help

    PHP Code:
    $cnt=0;
    while(
    $something mysql_fetch_array($querytrue && $cnt<100){
      
    //process....
      
    $cnt++;

    Will this work , or something like this I am trying to achieve

  • #2
    New Coder
    Join Date
    Aug 2010
    Posts
    53
    Thanks
    6
    Thanked 1 Time in 1 Post
    You can set the limit several ways.

    One way is by setting a limit on your query:

    PHP Code:
    $querymysql_query("SELECT * FROM Persons LIMIT 0,100");

    while(
    $row mysql_fetch_array($query))
      {
      echo 
    $row['FirstName'] . " " $row['LastName'];
      echo 
    "<br />";


    Another way is using the for method:

    PHP Code:
    for($i 0; ($condition) && $i 100$i++){ 
        
    //process 

    Your method should work fine as well but haven't tested it.

  • Users who have thanked Wuteverx1972 for this post:

    Vernk (10-10-2012)


  •  

    Posting Permissions

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