Jump to content

Recommended Posts

Hey everybody!

 

Maybe someone can help with the following...

 

I have a table with player names and their scores. To display the ranking I select names and scores and sort by scores desc.

Now I can while-loop my way through the whole list. No problems.. BUT:

 

Now I want to find only one persons position in the rankings table.

 

Imaginary Query:

SELECT row_number, names, scores FROM thetable WHERE name=\'$name\' ORDER BY scores desc

 

echo hey dude you are $row_number i nthe rankings!

 

How can I get this number? Do i need to make a temp field named ranking or something? Can I auto increment this temp field?

 

Id like to do this on the database side so i dont have to pull all data through the pipe for just one dude...

 

The scores change so often I dont want to save their positions in a field.

 

If I understand correctly, I think I need an inverse of mysql_data_seek. So instead of giving the pointer and getting the data, I need to give the data (name) and get the pointer (position in table).

 

Is this possible?

 

Cheers....

Link to comment
https://forums.phpfreaks.com/topic/278-find-row-number/
Share on other sites

Well,

 

I don\'t know if this will work, but I know that in Oracle you have

a statement called ROWID...so this would be like


SELECT    ROWID AS \'rank\', column1, column2

FROM       table

WHERE     rank = 2

 

I don\'t know if this will work ..., let me know

Link to comment
https://forums.phpfreaks.com/topic/278-find-row-number/#findComment-843
Share on other sites

auto increment was only intended to \"automatically\" assign a unique identifier for a new row. If it is important to your project that all of the entries have a field where each one is identified sequencially? You will have to do that manualy with the code. Maybe if you tell us why the holes are causeing you grief we can suggest a different way of doing things.

Link to comment
https://forums.phpfreaks.com/topic/278-find-row-number/#findComment-848
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • 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.