Sinikka Posted February 1, 2008 Share Posted February 1, 2008 I have a list that pulls the highest amount of books read by a pet and lists them in order by the amounts read. In the query I'm trying to remove duplicate owners from the list so it only shows the one pet per owner for the highest amount of books read. I've managed to get it to pull that but it's not pulling the correct pet, a few of them are but then it jumps and pulls a pet owned by a user that does have a pet that belongs in that space but completely wrong pet. I've tried just about everything I can think of in the last few days and I'm getting no where. Can anyone help me? $x = 1; $query = "SELECT DISTINCT `id`,`owner`, MAX(`book_count`) AS amount FROM `user_pets2` GROUP BY `owner` ORDER BY `amount` DESC LIMIT 25"; $result= mysql_query($query) or die ("Error in query " . mysql_error()); //whats the error?? while($row = mysql_fetch_assoc($result)) { $username = $row['id']; $number = $row['amount']; $pets2 = fetch("SELECT * FROM user_pets2 WHERE id = '$username' AND game = '1'"); $top .= " <tr><td width=33% valign=middle><div align=center><b><font face=verdana color=#0047BE>$x.</b></font> </div></td><td width=33% valign=middle> <A href=user_pets.php?game=1&id=$username><font face=verdana color=#0047BE>$pets2[name]</a> </td><td width=33% valign=middle><div align=middle><font face=verdana color=#0047BE>$number</font></div></td></tr>"; $x++; } Quote Link to comment https://forums.phpfreaks.com/topic/88849-query-display-issue/ Share on other sites More sharing options...
Sinikka Posted February 1, 2008 Author Share Posted February 1, 2008 Bump to see if anyone can help. Quote Link to comment https://forums.phpfreaks.com/topic/88849-query-display-issue/#findComment-455704 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.