Jump to content

[Q]Dont know how to call it


Minase

Recommended Posts

first sorry for title dont know how to call this thread.

i have 2 tables users and alliances

USERS (CID,CAPTURE) - CID=Clan ID,CAPTURE=some points

ALLIANCES (ID,PID) PID = Player ID

 

i want to make something like a top of alliances ordered by capture.but i dont know how to structure it dang it  :o

 

first i used a query to make a sum of alliances points

 

$capture = mysql_query("SELECT SUM(Capture) AS CaptureSum FROM `" . DBPREFIX . "users` where CID=1");

but now how i can order the alliances by variable $capture?

$rank = mysql_query("SELECT * FROM `" . DBPREFIX . "alliances` ORDER BY ????? DESC");

 

can i structure it into a query? if yes how please?

and this is more like a php subject cause is not just a query.at what im thinking now i need to use 2 variables (1 to select sum from users,and another to order).but i dont have a clue how to do it

 

simple explain:

I want to make a simple alliance ranking who would order results by $capture

Link to comment
https://forums.phpfreaks.com/topic/119488-qdont-know-how-to-call-it/
Share on other sites

Wasn't quite sure of how you wanted the data, but this seems to work as far as I can tell:

 

SELECT SUM(u.Capture) as capturetotal, u.id as pid FROM users AS u LEFT JOIN alliances AS al ON al.pid = u.id  GROUP BY al.pid ORDER BY capturetotal DESC;

thanks it worked but not how it was suposed i tryed editing it,but no luck...

http://img134.imageshack.us/img134/262/unbenanntau4.png

 

hope you understand better what i want to do in that picture if not let me explain again

 

first parse all aliances and sellect capture sum (from users) for every alliance.after that order them by capture.

hope you understand what i mean thanks

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.