theflea912 Posted March 28, 2009 Share Posted March 28, 2009 The title doesn't really provide enough of a description. I know PHP well enough that I could select an entry via WHERE and LIMIT clause. Here is the problem: I have a bunch of entries in a table, sorted by time (ASC so the "winning" time is the first entry). I need to find a users entry in that list and return its placement. So if they got 3rd place out of 5 people, it would return a 3, and so on. I have no idea how to do this. My first idea was to combine each row into an array, and than do array_search for the ID of the user, but that didn't work. How would you go about doing this? Quote Link to comment Share on other sites More sharing options...
Mchl Posted March 28, 2009 Share Posted March 28, 2009 http://arjen-lentz.livejournal.com/55083.html Quote Link to comment Share on other sites More sharing options...
theflea912 Posted March 29, 2009 Author Share Posted March 29, 2009 http://arjen-lentz.livejournal.com/55083.html Thanks for the quick response. I edited the SQL from one of the examples to: $new = "SELECT count(*) AS rank FROM (SELECT * FROM workouts WHERE distance='$distance_of' AND ranked='Yes' > (SELECT * FROM workouts WHERE rowerid='$userid_func' AND distance='$distance_of' AND ranked='Yes') ORDER BY time ASC)AS s"; When I run it though, I get "Operand should contain 1 column(s)". I do not know SQL really all that well, so can someone explain what is going on? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.