Jump to content

search criteria from array


mdnghtblue

Recommended Posts

$allies = mysql_query("SELECT num, clan FROM players WHERE clan=$users[clan];");

$market = mysql_query("SELECT * FROM market WHERE time<=$time AND seller=$allies;"); // not sure what to put instead of $allies?

 

How can I limit the second query to the sellers with the "num"s selected from the first query? I kinda doubt the way I set it up above works.

Link to comment
https://forums.phpfreaks.com/topic/92500-search-criteria-from-array/
Share on other sites

You mean "num" is the ID and seller is the ID from the clan/players table?

 

If so:

 

SELECT p.num, p.clan, m.*
FROM players AS p
INNER JOIN
market AS m ON ( m.seller = p.num )
WHERE m.time<=$time AND p.clan=$users[clan]

 

I'd rename "num"  as player_id and seller as seller_id (or player_id) to make this more obvious.

 

Also, make sure to quote those literals.

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.