SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Aug 2004
    Location
    Norway
    Posts
    355
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    While loop question

    Hi

    This is my code
    PHP Code:
    <?php 
    include "config.php";

        
    $get22 "SELECT gid, rating FROM ratings ORDER BY rating DESC, votes DESC LIMIT 10";
        
    $result22 = @mysql_query($get22);
            
        while (list (
    $gid$rating) = @mysql_fetch_row($result22))
        { 
             
    $get2 "SELECT gName FROM games WHERE gId = $gid LIMIT 1";
            
    $result2 = @mysql_query($get2);    
                            
            while (list (
    $name) = @mysql_fetch_row($result2))
            { 
                if(
    $seo_support == "1")
                { 
                    if(
    $seo_words == "1")
                    {
                        
    $game_name2 str_replace(" ""_""$name");
                        
    $stars round($rating);
                        
    $digits 10;

                        include 
    "name_replace.php";

                        if (
    $i $digits) {
                            echo 
    "<b>0".$i++."</b>";      
                        }
                        else {
                            echo 
    "<b>".$i++."</b>";  
                       }                                    
                            echo 
    "<a href=\"./play-$gid-$game_name2.html\" class=\"blackLink\"> $name</a> - <img src=\"images/s$stars.png\" /><br />";

                    } 
                        
                    else 
                    {
                        echo 
    "<a href=\"./play-$gid.html\"> $name</a> - $rating<br /> \n ";
                    } 
                } 

                else 
                { 
                    echo 
    "<a href=./index.php?action=play&id=$gid>$name</a>  - $rating<br>"
                } 
            }
        } 
    ?>
    The problem is that the first result dont get a #. Look here for a live test
    http://www.planetarcades.com/test.php


    Thanks

  2. #2
    SitePoint Guru gavwvin's Avatar
    Join Date
    Nov 2004
    Location
    Cornwall, UK
    Posts
    686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try:
    PHP Code:
    <?php
    include "config.php";

        
    $get22 "SELECT gid, rating FROM ratings ORDER BY rating DESC, votes DESC LIMIT 10";
        
    $result22 = @mysql_query($get22);
        
    $i 1;
        while (list (
    $gid$rating) = @mysql_fetch_row($result22))
        {
             
    $get2 "SELECT gName FROM games WHERE gId = $gid LIMIT 1";
            
    $result2 = @mysql_query($get2);    
                            
            while (list (
    $name) = @mysql_fetch_row($result2))
            {
                if(
    $seo_support == "1")
                {
                    if(
    $seo_words == "1")
                    {
                        
    $game_name2 str_replace(" ""_""$name");
                        
    $stars round($rating);
                        
    $digits 10;

                        include 
    "name_replace.php";

                        if (
    $i $digits) {
                            echo 
    "<b>0".$i."</b>";      
                        }
                        else {
                            echo 
    "<b>".$i."</b>";  
                       }
                       
    $i++                                 
                            echo 
    "<a href=\"./play-$gid-$game_name2.html\" class=\"blackLink\"> $name</a> - <img src=\"images/s$stars.png\" /><br />";

                    }
                        
                    else
                    {
                        echo 
    "<a href=\"./play-$gid.html\"> $name</a> - $rating<br /> \n ";
                    }
                }

                else
                {
                    echo 
    "<a href=./index.php?action=play&id=$gid>$name</a>  - $rating<br>";
                }
            }
        }
    ?>

  3. #3
    SitePoint Addict
    Join Date
    Aug 2004
    Location
    Norway
    Posts
    355
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you very much. That works excellent


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
  •