Hi People,

I'm brain-dead on this and really could do with some help with joining another query.

This is the original setup.

Code:
$ID = clean($_GET['ID']);
$ID = abs((int) ($ID));
$max = $gamesonpage;

if (!isset($_GET['page']))
    $_GET['page'] = null;

$show = clean($_GET['page']);
if(empty($show)){
	$show = 1;
}
$limits = ($show - 1) * $max; 
$r2 = "SELECT * FROM gp_games WHERE category='$ID' && active='1' ORDER BY ID ASC LIMIT ".$limits.",".$max ;
$sqltitle = "browse-cat".$ID."page".$show;
$r1 = sqlcache($sqltitle, $cachelife, $r2);
$totalres = mysql_result($db->query('SELECT COUNT(ID) AS total FROM gp_games WHERE active=\'1\' and category=\''.$ID.'\''),0);
$totalpages = ceil($totalres / $max);
And I'm trying to add this below to return one result that needs the gp_games category='$ID' from gp_games to match the gp_categories.id and return a single gp_categories name;

Code:
$query = "SELECT DISTINCT gp_games.category, gp_categories.ID, gp_categories.name ".
"FROM gp_games, gp_categories ".
"WHERE gp_games.category = gp_categories.id";
	 
$result = mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_array($result)){

echo ''.$row['name'].'', ' -', ' ', $l_page, ' ', '»', ' ', $show;
echo "<br />";
}
This is what I've got so far, and I've tried everything I know about, and some that I don't to get a single return per category! And all I'm doing is going around in circles.

Action - Page 1
Shooter - Page 1
Other - Page 1
Sport - Page 1
Puzzle - Page 1
Arcade - Page 1
Mario - Page 1
Wheels - Page 1
Dress Up - Page 1
Memory - Page 1
Strategy and TD - Page 1
Colouring In - Page 1
Jigsaws - Page 1
Words - Page 1
Cooking - Page 1
Dora and Diego - Page 1