MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 2nd, 2012, 09:00 PM
slopalong slopalong is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 1 slopalong User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 2 sec
Reputation Power: 0
How do I join two queries when both have $ID's

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

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > How do I join two queries when both have $ID's

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap