Hi

I have a similar problem posted in this thread:
http://www.sitepoint.com/forums/show....php?p=4327892

I'm building an trainingblog site and I want to show the strongest members in the selected exercise and repetition.

I only want to show the max kg for each user.

Its now showing wrong max for user.

Code MySQL:
$result = mysql_query("SELECT
	users.user_id,
	users.user_country,
	lifts.kg,
	lifts.url,
	training.place,
	training.date,
	training.training_id,
	training.bodyweight
	FROM lifts, training, users
	WHERE lifts.rep = ". $nr_reps ." 
	AND lifts.exercise_id= ". $ex_id ." 
	AND training.training_id = lifts.training_id 
	AND training.user_id = users.user_id 
           GROPU BY user_id
	ORDER BY kg DESC, ABS(bodyweight) ASC, training.date ASC") or die(mysql_error());

And here is the php code for viewing.
Code PHP:
$num = mysql_num_rows($result);
$i=1;
if($i <= $num)
{ 
		echo "<table border='1' width='100%'>";
		echo "<tr><th>#</th><th>" . ucf(translate('name')) . "</th><th>" . ucf(translate('country')) . "</th><th>" . ucf(translate('place')) . "</th><th>" . translate('date') . "</th><th>" . ucf(translate('bodyweight')) . "</th><th>". translate('lifted') ."</th></tr>";
 
 
		while($row = mysql_fetch_array( $result )) 
		{
			echo "<tr";  
			if($i == 1): echo " style='background-color:#F9F99F;'"; endif; if($i == 2): echo " style='background-color:#F6F9F9 ;'"; endif; if($i == 3): echo " style='background-color:#EBC79E;'"; endif; echo ">";
			echo "<td align='center'>";
			if($i == 1): echo "<img src='img/gold.png' />"; endif;
			if($i == 2): echo "<img src='img/silver.png' />"; endif; 
			if($i == 3): echo "<img src='img/bronze.png' />"; endif; 
			echo "<b>" . $i++ . "</b>";
			echo "</td>
 
			<td align='center'>";
			echo "<b><a style='color:#555555;' href='index.php?action=profile&id=". $row['user_id'] ."'>" . getNameFromId($row['user_id']) . "</a></b>"; 
			echo "</td>
 
			<td align='center'>";
			echo "<div><img src='img/flags/16/". strtolower($row['user_country']) .".png' /></div> " . translate(ucf(getCountryName(strtolower($row['user_country'])))) . "";
			echo "</td>
 
			<td align='center'>";
			echo $row['place'];
			echo "</td>
 
			<td align='center'>";
			echo formatDate($row['date'], $dateformat);
			echo "</td>
 
			<td align='center'>";
			echo r_nr2(calcFromKg($row['bodyweight'])). $w_metric;
			echo "</td>
 
			<td align='center'>"; 
			echo "<a style='color:#555555;' href='index.php?action=profile&sub=show&tid=". $row['training_id'] ."'>";
			if($w_metric == "kg")
			{
			echo "<b>" .  r_nr2(calcFromKg($row['kg'])). $w_metric . "</a></b>";
				if($row['url'] != "")
				{
					echo " <a href='" . $row['url'] . "' target='_blank'><img title=". translate('show_video') ." src='img/video.png' /></a>";
				}
			}
			else
			{
			echo "<b>" .  r_nr(calcFromKg($row['kg'])). $w_metric . "</a></b>";
				if($row['url'] != "")
				{
					echo " <a href='" . $row['url'] . "' target='_blank'><img title=". translate('show_video') ." src='img/video.png' /></a>";
				}
			}
			echo "</td>
			</tr>"; 
 
		}
 
		echo "</table>

r937 ?