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 Link to comment https://forums.phpfreaks.com/topic/34060-rank-results-mysql/ 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 Link to comment https://forums.phpfreaks.com/topic/34060-rank-results-mysql/#findComment-160112 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 Link to comment https://forums.phpfreaks.com/topic/34060-rank-results-mysql/#findComment-160114 Share on other sites More sharing options...
papaface Posted January 13, 2007 Author Share Posted January 13, 2007 Thanks :) Link to comment https://forums.phpfreaks.com/topic/34060-rank-results-mysql/#findComment-160115 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.