Post High Score and Retrieve Position

Posted by majman on Stack Overflow See other posts from Stack Overflow or by majman
Published on 2010-03-16T18:04:29Z Indexed on 2010/03/16 18:21 UTC
Read the original article Hit count: 242

Filed under:
|
|

I'm not so savvy with MYSQL, so my apologies in advance is this is a dumb question.

I've created a super basic PHP High Scores table. Upon inserting a new score into the DB Table, I'd like to retrieve the position of that score so that I can get 10 results with the persons score falling within that range.

My INSERT Query looks something like:

$stmt = $mysqli->prepare("INSERT INTO highscores (name, time, score) VALUES (?, ?, ?)");
$stmt->bind_param('sdi', $name, $time, $score);

UPDATE - I'm looking for a way to do this with as few queries as possible. I recall reading something about getting an INSERT ID when making an insert, but I would then still have to make a second query to get those results.

© Stack Overflow or respective owner

Related posts about php

Related posts about highscores