Hi all

I am trying to create a days since last login being displayed on my members list i have attempted to create it but i have no idea why it will not work any futhure for all members

this is what i have so far.

Code:
for($i=24; $i >= 1; $i--)
					{
						$uQuery="SELECT * FROM members where disable='1' and rank = $i ORDER by `mid` LIMIT $start, $limit";//
						$result=mysqli_query($con,$uQuery);
						if(!$result)
						{
							echo "Error:".mysqli_error($con);
						}
						else
						{
							$count=$rs->num_rows; 
							if($count>0) 
							$rank=$data['rank'];
							$disable=$data['disable'];
							while($data=mysqli_fetch_array($result))
							{
								extract($data);
								{
							echo "<tr>
							<td width=\"20\">";
							if($data['rank']==1)
							{
								echo "<font color=".$fontcolor.">Recruit</font>";
							}
							if($data['rank']==2)
							{
								echo "<font color=".$fontcolor.">Private</font>";
							}
							if($data['rank']==3)
							{
								echo "<font color=".$fontcolor.">Corporal</font>";	
							}
							if($data['rank']==4)
							{
								echo "<font color=".$fontcolor.">Sergeant</font>";	
							}
							if($data['rank']==5)
							{
								echo "<font color=".$fontcolor.">Sergeant First Class</font>";	
							}
							if($data['rank']==6)
							{
								echo "<font color=".$fontcolor.">Master Sergeant</font>";	
							}
							if($data['rank']==7)
							{
								echo "<font color=".$fontcolor.">First Sergeant</font>";	
							}
							if($data['rank']==8)
							{
								echo "<font color=".$fontcolor.">Sergeant Major</font>";	
							}
							if($data['rank']==9)
							{
								echo "<font color=".$fontcolor.">Warrant Officer WO1</font>";	
							}
							if($data['rank']==10)
							{
								echo "<font color=".$fontcolor.">Chief Warrant Officer CWO2</font>";	
							}
							if($data['rank']==11)
							{
								echo "<font color=".$fontcolor.">Chief Warrant Officer CWO3</font>";	
							}
							if($data['rank']==12)
							{
								echo "<font color=".$fontcolor.">Chief Warrant Officer CWO4</font>";	
							}
							if($data['rank']==13)
							{
								echo "<font color=".$fontcolor.">Master Warrant Officer CWO5</font>";	
							}
							if($data['rank']==14)
							{
								echo "<font color=".$fontcolor.">Second Lieutenant</font>";	
							}							
							if($data['rank']==15)
							{
								echo "<font color=".$fontcolor.">First Lieutenant</font>";	
							}
							if($data['rank']==16)
							{
								echo "<font color=".$fontcolor.">Captain</font>";	
							}
							if($data['rank']==17)
							{
								echo "<font color=".$fontcolor.">Major</font>";	
							}
							if($data['rank']==19)
							{
								echo "<font color=".$fontcolor.">Colonel</font>";	
							}
							if($data['rank']==20)
							{
								echo "<font color=".$fontcolor.">Brigadier General</font>";	
							}
							if($data['rank']==21)
							{
								echo "<font color=".$fontcolor.">Major General</font>";	
							}
							if($data['rank']==22)
							{
								echo "<font color=".$fontcolor.">Lieutenant General</font>";	
							}
							if($data['rank']==23)
							{
								echo "<font color=".$fontcolor.">General</font>";	
							}
							if($data['rank']==24)
							{
								echo "<font color=".$fontcolor.">Commander</font>";	
							}
							if($data['rank']==25)
							{
								echo "<font color=".$fontcolor.">Webmaster</font>";	
							}
											echo "</td>"; 
											echo "<td><a href=\"index.php?cmd=profile&mid=".$data['mid']."\">".$data['username']."</font></a>"; 
											echo "<td><a href=aim:goim?screenname=".$data['aim']."&message=Hi.+Are+you+there?>".$data['aim']."
											</a></font><td>$calcDSL;</td></tr>";
								}
							}
						}
					}
i had a function to do this

Code:
function calcDSL($username)
{
  $today=date("F j,Y,g:i a");
  $cQuery="SELECT TO_DAYS($today)-TO_DAYS(LastedLogin) FROM members WHERE username = \"$username\"";
  $result = mysqli_query($con,$cQuery);
  $days = mysqli_fetch_array($result);
  return $days[0];
}
1 problem it doesnt show anything only the first member in the list not all of them.

How can that be done so display last time the person logged in.

And also i have another issue i would like to be made eaiser that is a dynamic ranking system

which display name of ranks coming from database

this i what i am using at the moment

Code:
if($data['rank']==1)
							{
								echo "<font color=".$fontcolor.">Recruit</font>";
							}
							if($data['rank']==2)
							{
								echo "<font color=".$fontcolor.">Private</font>";
							}
							if($data['rank']==3)
							{
								echo "<font color=".$fontcolor.">Corporal</font>";	
							}
							if($data['rank']==4)
							{
								echo "<font color=".$fontcolor.">Sergeant</font>";	
							}
							if($data['rank']==5)
							{
								echo "<font color=".$fontcolor.">Sergeant First Class</font>";	
							}
							if($data['rank']==6)
							{
								echo "<font color=".$fontcolor.">Master Sergeant</font>";	
							}
							if($data['rank']==7)
							{
								echo "<font color=".$fontcolor.">First Sergeant</font>";	
							}
							if($data['rank']==8)
							{
								echo "<font color=".$fontcolor.">Sergeant Major</font>";	
							}
							if($data['rank']==9)
							{
								echo "<font color=".$fontcolor.">Warrant Officer WO1</font>";	
							}
							if($data['rank']==10)
							{
								echo "<font color=".$fontcolor.">Chief Warrant Officer CWO2</font>";	
							}
							if($data['rank']==11)
							{
								echo "<font color=".$fontcolor.">Chief Warrant Officer CWO3</font>";	
							}
							if($data['rank']==12)
							{
								echo "<font color=".$fontcolor.">Chief Warrant Officer CWO4</font>";	
							}
							if($data['rank']==13)
							{
								echo "<font color=".$fontcolor.">Master Warrant Officer CWO5</font>";	
							}
							if($data['rank']==14)
							{
								echo "<font color=".$fontcolor.">Second Lieutenant</font>";	
							}							
							if($data['rank']==15)
							{
								echo "<font color=".$fontcolor.">First Lieutenant</font>";	
							}
							if($data['rank']==16)
							{
								echo "<font color=".$fontcolor.">Captain</font>";	
							}
							if($data['rank']==17)
							{
								echo "<font color=".$fontcolor.">Major</font>";	
							}
							if($data['rank']==19)
							{
								echo "<font color=".$fontcolor.">Colonel</font>";	
							}
							if($data['rank']==20)
							{
								echo "<font color=".$fontcolor.">Brigadier General</font>";	
							}
							if($data['rank']==21)
							{
								echo "<font color=".$fontcolor.">Major General</font>";	
							}
							if($data['rank']==22)
							{
								echo "<font color=".$fontcolor.">Lieutenant General</font>";	
							}
							if($data['rank']==23)
							{
								echo "<font color=".$fontcolor.">General</font>";	
							}
							if($data['rank']==24)
							{
								echo "<font color=".$fontcolor.">Commander</font>";	
							}
							if($data['rank']==25)
							{
								echo "<font color=".$fontcolor.">Webmaster</font>";	
							}
The Only problem is the ranks is coming from the ranks table which has these fields

-rid
-rankname
-rankcontent

Since the name of the ranks coming from the same field how can i make it display the names i got told to use an array but i am still unsure how to do that.

Thanks if you can help me with these to problems ill be very greatful