Andy said that the points were in the users table. Table layouts would
have been useful. It sounds to me as though the users table has not got
its points up to date and needs updating from the scores table first.
Then do the select on just the users table.
My 2p (pence, I'm in the UK so we're not in the Dollar or Euro zone, yet!)
Lazor, Ed wrote:
>I'm not sure if I completely understand what you're asking, but....
>It sounds like one table has user information. The second table has a
>record for each user and a field for the total number of points of each
>user. Something like this:
>Users (Table 1)
>Scores (Table 2)
>If this isn't the case, well, you'll probably want to adjust your database
>structure. This approach allows you to do a simple SQL query like this:
>select Users.*, Scores.* from Users, Scores where Users.ID = Scores.UserID
>ORDER BY Scores.Points limit 5
>From: andy [mailto:[EMAIL PROTECTED]]
>Sent: Wednesday, July 10, 2002 10:52 AM
>To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
>Subject: [PHP] sort problem
>I have a problem sorting values comming out of a db. It is not as easy.
>Here is the prob:
>One table containing user points.
>Other table containing reports with rankings
>For each top 10 report (the 10 reports with the most ranking) there are 20
>extra points granted
>Now I would like to get the top 5 members out of the db. If I only pull out
>the user table ordered by points desc limit 5 I might miss a user with a top
>10 report and 20 extra points.
>So I thought about sorting the array afterwards with asort, but then I loose
>the asoziation with the user_id.
>Maybe there is a way to sort the other arrays with the same sorting algo? Or
>a way to include a iff clause in the query?
>currently I am doing:
> points > 0
>ORDER by points desc
>and the top10 reports extra.
>Has anybody a good idea on that?
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php