473,387 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

display different user in rank

155 100+
Hello .

i got a list of user with ranking . i want to display the first five places where it is not the same user, like that

john : is rank 1
john
john
david : is rank 2
albert : is rank 3
albert
john <========== he is allready rank at 1 ,so is out of the list
john <========== he is allready rank at 1 ,so is out of the lis
eric : is rank 4
sam : is rank 5

there is 5 place ,5 winners ,winner cannot be in more then one place.

any help please ,thanx!!
Sep 2 '09 #1
6 1844
Dormilich
8,658 Expert Mod 8TB
that depends on the type of list. if it’s fetched from DB you can use SELECT DISTINCT, if it’s an array you can use array_unique() (to name 2 possibilities)
Sep 3 '09 #2
canabatz
155 100+
and how can i limit the result to 5 users only?

i cannot use limit on that select.

thanx
Sep 3 '09 #3
Markus
6,050 Expert 4TB
Use array_unique() and then array_slice().

Expand|Select|Wrap|Line Numbers
  1. $arr = array(
  2.     1, 1, 2, 2, 3, 3, 4, 4, 5, 5
  3. );
  4.  
  5. print_r(array_slice(array_unique($arr), 0, 4));
  6.  
Sep 3 '09 #4
canabatz
155 100+
im trying to put the array in a loop ,and it is not working for me ,i get only one result!

this is the code im trying to work on:
Expand|Select|Wrap|Line Numbers
  1. $sqlhis="select *  from bidding_details where bid_id=$bid_id and sortbid = '1' order by  bid_price desc ";
  2. $queryhis=mysql_query($sqlhis);
  3.  
  4. while ($rowhis=mysql_fetch_array($queryhis)){
  5. $username=$rowhis['username'];
  6.  $arr = array(
  7.    $username 
  8. );
  9.  
  10. }  
  11.  
  12. $arr=(array_slice(array_unique($arr), 0, 5));
  13.  
  14. echo $arr[0] . "<br />";
  15. echo $arr[1] . "<br />";
  16. echo $arr[2] . "<br />";
  17. echo $arr[3] . "<br />";
  18. echo $arr[4] . "<br />";
any idea , im new in this php world :)

thanx
Sep 3 '09 #5
Dormilich
8,658 Expert Mod 8TB
use
Expand|Select|Wrap|Line Numbers
  1. $arr[] = $username;
currently you’re overwriting your variable each time.

note: this is where Database Abstraction Layers come in handy, they (some) allow you to get the result array at once.
Sep 3 '09 #6
canabatz
155 100+
thanx alot man ,that fixed my work!! tahnx to all that helped !!!


it's perfect :)
Sep 3 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: kindermaxiz | last post by:
hi there i have a mysql table and i want the user to add columns using a php interface and then display the table with the newly added column. I was thinking about putting all the columns...
4
by: smilesinblues | last post by:
Hi, I have seen this on google and MSN. Google groups has star on which if you click the topic becomes stared... MSN has 5 stars to get feedback from user for giving rank to the pages. Sorry I...
3
by: Iain Hallam | last post by:
Hi. I've been using display:none on the style property of some <option> elements in my forms, which works fine with Mozilla - as expected it removes the option from my dropdown (although it...
10
by: Can | last post by:
I am creating an on-line survey. I want the user to have a list of choices of say 10 items that are radio buttons. They need to rank their preference. They click on preference 1, that option is...
17
by: kimimaro | last post by:
How do you limits employee display where you enter the department for all the employee within that department be displayed and if lets say they are 100 or so and you have to limits 10 employee per...
1
by: Joe | last post by:
Has anyone written a percentile rank algorithm that they can share or know of a good resource that defines the algorithm. I'm starting a project that involves percentile ranks, logistic and linear...
13
by: Steve Edwards | last post by:
Hi, Given a map: typedef map<long, string, greater<long> > mapOfFreq; Is there a quicker way to find the rank (i.e. index) of the elememt that has the long value of x? At the moment I'm...
1
by: volunteer | last post by:
<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="filename.xsl"?> <markers date="20060523"> 04:21:50 PM <marker sn="1" rank="6" name="john" /> <marker sn="2" rank="5"...
4
by: dipperdan | last post by:
Hi, I am working on a plant database and I need some help with a query that i *thought* shouldn't have been too hard =\ I am trying to create a query that will display the names contained in 4...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.