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
https://forums.phpfreaks.com/topic/29854-how-to-skip/
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
https://forums.phpfreaks.com/topic/29854-how-to-skip/#findComment-137189
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
https://forums.phpfreaks.com/topic/29854-how-to-skip/#findComment-137228
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
https://forums.phpfreaks.com/topic/29854-how-to-skip/#findComment-137230
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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