Jump to content

Clipping the last number


pugboy

Recommended Posts

For some reason, the script outputs the numbers 1-9 correctly, then outputs 10 "1"s, like it is outputting the first number but not the last... Same for when it gets into the 20s, 30s, 40s, and 50s...

 

    include("connect.php");
		$uid = $_COOKIE["uid"];
		$user = $_COOKIE["user"];
		$q = "SELECT * FROM avatars";
		$result = mysql_query($q);
		$i = 0;
		while($row = mysql_fetch_array($result)){
			$aid[$i] = $i+1;
			$uid[$i] = $row["uid"];
			$url[$i] = $row["url"];
			$rating[$i] = $row["rating"];
			$i++;
		}
		$start = $_GET["start"] - 1;
		$show = $_GET["show"];
		if($show=="" or $show>100)
			$show = 25;
		if($start=="" or $start<0 or $start>count($uid))
			$start = 0;
		$max = $start+$show;
		$key = $start;

 

 

Later in the page...

$startm = $start - $show;
	if($start>1)
		echo "<a href='browse.php?start=$startm&show=$show'>Previous $show</a>   ";
	if($max<count($uid))
		echo "<a href='browse.php?start=$max&show=$show'>Next $show</a>";

 

 

 

And Later...

while($key<$max){
			$uidv = $uid[$key];
			$q = "SELECT username FROM user WHERE id='" . $uidv . "'";
			$result = mysql_query($q) or die(mysql_error());
			list($creator) = mysql_fetch_array($result);
			$urlv = $url[$key];
			$ratingv = $rating[$key];
			$aidvalue = $aid[$key];
			echo "<tr><td  style='border-bottom: 1px #5A5A5A dashed; width: 121px'><a href='avatar.php?id=$aidvalue'><font size='15px'>$aidvalue</font></a></td><td  style='border-bottom: 1px #5A5A5A dashed; width: 322px'><font size='13px'><a href='profile.php?id=$uidv'>$creator</a></font></td><td  style='border-bottom: 1px #5A5A5A dashed;' width: 225px><a href='avatar.php?id=$aidvalue'><img style='border: none;' src='$urlv' width='80' height='97'/><a/></td><td style='border-bottom: 1px #5A5A5A dashed;' ><font size='15px'>$ratingv/10</size></td></tr>";
			$key++;
			if($key==count($uid))
				break;
		}

 

 

 

I have no clue what could be wrong! Seems like it would be a stupid error on my part.

 

Link to comment
https://forums.phpfreaks.com/topic/114867-clipping-the-last-number/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.