Jump to content

how to Skip!


asterixvader

Recommended Posts

hello.
i'm new to php and i got stuck in this part of what i want to do.
what i want to do is:

get information from a database and show it in a page, like a ranking:

$query ="select top 5 name,rank,marks from people order by marks desc";

but if rank = 5, i want it to skip that row and go to the next, how can i do that?

thanks.
Link to comment
Share on other sites

oh, no. with "row" i meant the row in sql database.

you know, sql window is like this:

"data in table 'people' in 'yyy' in '(local)'"
Name / Rank / Marks
--------------------------
Name1/ 3 / 5  ............<-- "row"
Name2/ 5 / 32 ...........<-- skip this "row" (because rank = 5)
Name3/ 3 / 9 .............<-- and continue with this "row"
Name4/ 2 / 1 .............<-- another "row"

(are they even called "rows" ?)
they will show in a table in a webpage, i have the code to do that.
but what i want to know is how can i make it skip a "row" IF rank = 5 so it won't show it in the page. do you understand what im trying to say? im not good explaining things.
Link to comment
Share on other sites

no no, you dont understand.

let's say i want to make a "top 5 ranking". i will get the info from the table "people" , i will order them by "rank" and show the "top 5 ranking" in a webpage.
ok, i know how to do that part.

but i don't want to show the "people" whose rank='5'. i just want to show "people" with any rank except 5 (1, 2, 3, 4, 6, 7, etc).

so with the example i posted (the sql window), the webpage should show this:

name - rank - marks
name1 - 3 - 5
name3 - 3 - 9
name4 - 2 - 1
etc
etc

where is name2? it didn't show because its rank=5. that's what i want to do.
that's why i ask, how can i make it "skip" rows where rank=5.
Link to comment
Share on other sites

Which is why I said [b]where rank != 5[/b].  I can't tell you the exact syntax, but that should get you started.

That should give you the records in which "Rank" is NOT 5.  If you want to tell it to include only people with a rank of LESS than 5 it'd be something like [b]where rank < 5[/b].
Link to comment
Share on other sites

"select top 5 name..."

TOP is a MS SQL thing. If that's what you're using and what you want to do, thats fine. It limits the results to the first n rows. It doesn't really fit in with what you are trying to do. And if you are using mysql it will just error out.
Link to comment
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.