papaface Posted January 13, 2007 Share Posted January 13, 2007 Hello,Please help me :)How would I go about displaying a 1,2,3,4 etc up to the total amount of results for the query?Here is my code[code]<?phprequire ('includes/connect.php');$grab = mysql_query("select * from submissions order by inbound desc ",$con) or die (mysql_error());while ($row = mysql_fetch_array($grab)) { echo '<a href="out.php?out='.$row['subid'].'">'. $row['sitename']. "</a>" . "<br>"; }?>[/code]I would like to rank the results therefore I need the first time it goes through the while loop to print a '1' next to the link.Any ideas?regards Quote Link to comment Share on other sites More sharing options...
Destruction Posted January 13, 2007 Share Posted January 13, 2007 Before the while loop put$count = 1;Inside the loop use $count++ where you want the number displayedDest Quote Link to comment Share on other sites More sharing options...
JJohnsenDK Posted January 13, 2007 Share Posted January 13, 2007 Yes or you could use a for loop.[code]<?php$row = mysql_fetch_array($grap);for($i = 1; $i > $row; $i++){ echo '<a href="out.php?out='.$row['subid'].'">'. $row['sitename']. "</a>" . "<br>";}[/code]JJohnsenDK Quote Link to comment Share on other sites More sharing options...
papaface Posted January 13, 2007 Author Share Posted January 13, 2007 Thanks :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.