Jump to content
php.lv forumi

kopējais rangs


anonīms

Recommended Posts

ir db lietotaji, kur ir kollonas nba_rating, nhl_rating, uefa_rating un ir nepieciešams šos reitingus saskaitīt un tad no visiem lietotājiem kopā iedalīt vietu.

Mēģināju kaut ko šādu:

http://paste.php.lv/5dd5908708f079f904c8f02630f42ab3?lang=php

bet izmet error

Invalid use of group function

 

Mēģināju pēc šī koda, ko diezgan pasen iedeva marcis. (kods der ideāli, ja nepieciešams tikai aprēķināt rangu pēc vienas no spēlēm (nhl_rating, etc.))

SELECT *, rating AS myrating, (SELECT COUNT(DISTINCT(rating))+1 FROM `table` WHERE rating>myrating) AS rank FROM `table` WHERE id=$id

Avots: http://php.lv/f/topic/13621-izvadam-kura-vieta-ir-pec-kaut-ka/page__hl__ranks__fromsearch__1

Kādi to varētu dabūt gatavu?

Edited by anonīms
Link to comment
Share on other sites

izvada pilnīgi visiem lietotājiem, ka ir pirmā vieta.

$ranga_vieta = mysql_query("
SELECT id, lietotajvards, nhl_rating+uefa_rating+nba_rating AS myrating,
(SELECT COUNT(DISTINCT(nhl_rating+nba_rating+uefa_rating))+1 FROM bliezam_lietotaji
WHERE nhl_rating+uefa_rating+nba_rating > myrating ORDER BY id DESC) AS ranga_vieta FROM bliezam_lietotaji ORDER BY ranga_vieta") or die(mysql_error());

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...