Sinikka Posted February 4, 2008 Share Posted February 4, 2008 I have a query to pull info by owner, pet id and amount of books they've read but I can't get it to display correctly on a web page. Here's my query that I currently have: $x = 1; $query = "SELECT DISTINCT `user_pets2`.`owner` , `read2`.`pet_id` , `user_pets2`.`id` , MAX( `user_pets2`.`book_count` ) AS amount FROM `read2` , `user_pets2` WHERE `read2`.`pet_id` = `user_pets2`.`id` GROUP BY `user_pets2`.`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/89327-solved-help-please/ Share on other sites More sharing options...
Stooney Posted February 4, 2008 Share Posted February 4, 2008 You need to be more specific on the problem. What is the expected output and the actual (currently incorrect) output? Quote Link to comment https://forums.phpfreaks.com/topic/89327-solved-help-please/#findComment-457415 Share on other sites More sharing options...
Sinikka Posted February 4, 2008 Author Share Posted February 4, 2008 The output I need is a top 25 list ordering like this: 1. petname bookcount right now all I'm getting is: 1. Quote Link to comment https://forums.phpfreaks.com/topic/89327-solved-help-please/#findComment-457417 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.