Need some help on puting numbers to a ranking

Discussion in 'PHP' started by casperz, Jun 14, 2009.

  1. #1
    Hello i would like to ask for some help with this code what i want is that in the rank appear
    s like the position for example,
    1.blalba
    2.dada
    3.adada

    my actual code does not have that can some one help me this is my acutal code,
     $conn = mysql_connect($host,$user,$pass) or die("Unable to connect to MySQL server");
    
     mysql_select_db($db,$conn) or die("Unable to select to MySQL database");
     
    		$query = "select playlist.id as playlist_id, playlist.user_id, playlist.username, playlist.playlist_name as playlist_name from playlist where playlist.user_id = '0' order by playlist.views desc limit 7"; 
    						
    		$results = mysql_query($query); 		
    
    
    		
    
    
    
    
    
    		if(!$results) 
    		{
    			echo 'query failed'; 
    		}
    		else 
    		{
    			while($row=mysql_fetch_assoc($results))
    			{
    				
    				
    				
    				$songName = $row['playlist_name'];  
    				print(""); 
    				/*print("<td ><a href='songs.php?id=".$row['song_id']."'><img src='$artistPhoto' width='25' height='20'/></a></td>");*/
    				print("<p style='font-family:century gothic; font-weight:normal; color: #3e3b2f; text-transform:lowercase; letter-spacing:1px;' >.<a href='playmyplaylist.php?pl_id=".$row['playlist_id']."&name=$songName'>$songName</a>
    			</p>");
    				print("");				
    				print("");  
    			}
    		}		
    	
    
    
    
    PHP:
    Thanks
     
    casperz, Jun 14, 2009 IP
  2. Vbot

    Vbot Peon

    Messages:
    107
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    $count = 1;
    while($row=mysql_fetch_assoc($results))
    {
            $songName = $row['playlist_name']
            echo "{$count}.{$songName}";
            $count++;
    }
    PHP:
     
    Vbot, Jun 14, 2009 IP
  3. casperz

    casperz Guest

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks alot
     
    casperz, Jun 14, 2009 IP