asterixvader Posted December 7, 2006 Share Posted December 7, 2006 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. Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted December 7, 2006 Share Posted December 7, 2006 Are you talking about starting a new row in an HTML table every [i]n[/i]th record? Quote Link to comment Share on other sites More sharing options...
asterixvader Posted December 8, 2006 Author Share Posted December 8, 2006 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. Quote Link to comment Share on other sites More sharing options...
doni49 Posted December 8, 2006 Share Posted December 8, 2006 I'm not the best at SQL yet, but try putting this on the end of the query: [b]where rank != 5[/b]and yes, they're called rows. Quote Link to comment Share on other sites More sharing options...
insrtsnhere13 Posted December 8, 2006 Share Posted December 8, 2006 well.. if your table is large and have enough people you should be able to do this.. ORDER BY rank ASC Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted December 8, 2006 Share Posted December 8, 2006 no do this[CODE]<?php$sql = mysql_query("SELECT * FROM people WHERE rank NOT LIKE rank ORDER BY marks desc"){while ($row = mysql_fetch_assoc($sql)){echo 'Table Stuff here';}?>[/code] Quote Link to comment Share on other sites More sharing options...
asterixvader Posted December 8, 2006 Author Share Posted December 8, 2006 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 - marksname1 - 3 - 5name3 - 3 - 9name4 - 2 - 1etcetcwhere 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. Quote Link to comment Share on other sites More sharing options...
doni49 Posted December 8, 2006 Share Posted December 8, 2006 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]. Quote Link to comment Share on other sites More sharing options...
asterixvader Posted December 8, 2006 Author Share Posted December 8, 2006 ohh yes doni49, you were right, it works! sorry, i didn't test it well the first time.thanks everyone! Quote Link to comment Share on other sites More sharing options...
artacus Posted December 8, 2006 Share Posted December 8, 2006 "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. 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.