SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard Darren884's Avatar
    Join Date
    Aug 2003
    Location
    Southern California, United States
    Posts
    1,616
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    WHat is wrong with my looping code?

    It returns thousands of results instead of just a coupl when there are 7 results displayed...?

    PHP Code:
    <?php

    if ($total 5)
    {
        
    $half = ($total/5);
        
    $pages ceil($half);
        echo 
    "            <strong>Page:</strong>";
        
    $page 1;
        for (
    $iterations <= $pages) {
            
    $delimiter = ($page+1);
            if (
    $delimiter == $pages) {
                echo 
    " <a class=\"website\" href=\"{$_SERVER['REQUEST_URI']}/$page/\" alt=\"Page $page\">$page</a>\n";
            } else {
                echo 
    " <a class=\"website\" href=\"{$_SERVER['REQUEST_URI']}/$page/\" alt=\"Page $page\">$page</a>,";
            }
            
    $page++;
        }
    }

    ?>
    Have a good day.

  2. #2
    SitePoint Evangelist
    Join Date
    Feb 2005
    Posts
    581
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Where is "$iterations" coming from?

    I would probably do the loop like this:

    PHP Code:
    for ($i 0$i <= $pages$i++) 
    I will not flame the newbies,
    I will not flame the newbies,
    I will flame the newbies...
    Table free is the way to be!

  3. #3
    SitePoint Guru
    Join Date
    Oct 2006
    Location
    Queensland, Australia
    Posts
    852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    your for loop is invalid. you're trying to use a for loop like a while loop. I'd do what BluDragon suggested above, but it's hard to know what's going on with knowing where $iterations comes from, or what data it may contain.


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
  •