Jump to content

Double Query help?


whiteboikyle

Recommended Posts

Okay well here is my long php query..

 

select username, image, ranks.rName, members.ID, timestamp, aim, categories.ID, categories.name
				from members, ranks, ranklookup, categories
				where members.rank = ranks.id
				and ranks.id = ranklookup.rid
				and categories.id = ranklookup.cid
				and categories.id = ' . $cid . '
				and disabled = 0
				ORDER BY ranks.ID desc;

 

now there is 2 ID's that come up in this situation..

 

1 ID is for the ranks.. and the other ID is the members.. So would i echo either 1 using $row = mysql_fetch_array($result);

if i put $row['ID'] it could get confused?

Link to comment
https://forums.phpfreaks.com/topic/114161-double-query-help/
Share on other sites

It'd spit out it's dummy and say that it can't tell which you want;

 

Try using:

 

select username, image, ranks.rName, members.ID as memID, timestamp, aim, categories.ID as catID, categories.name
				from members, ranks, ranklookup, categories
				where members.rank = ranks.id
				and ranks.id = ranklookup.rid
				and categories.id = ranklookup.cid
				and categories.id = ' . $cid . '
				and disabled = 0
				ORDER BY ranks.ID desc;

 

then use $row['catID'] and $row['memID'] as required :)

Link to comment
https://forums.phpfreaks.com/topic/114161-double-query-help/#findComment-586927
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.