hi friends... Thanks for your suggestions..but i could not get the exact rank list properly.. My code is as below.. $sql2="SELECT * FROM rank"; $result=mysql_query($sql2,$con); $num=mysql_num_rows($result); for($i=0;$i<$num;$i++) { $f1=mysql_result($result,$i,"regno"); $d6=mysql_result($result,$i,"total"); $d7=mysql_result($result,$i+1,"total"); $d8=mysql_result($result,$i,"rank"); if($d6==$d7) { $sql8="UPDATE $_POST[test] set rank='$i'+1 where total='$d6'"; mysql_query($sql8,$con); } else if($d6!=$d7) { $sql1="UPDATE $_POST[test] SET rank='$i'+1 WHERE regno='$f1'"; mysql_query($sql1,$con); } But if i use while loop as you people said..No such list is obtained. Please check and tell if i could do any changes in the above code.. Also if any two students has secured the same total they has to be given the same rank..Till now it generates the rank but in this order...1 2 3 4 7 7 7..As the last 3 students has the got same total.. any suggestion regards --Bavithra