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!!
6 1844
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)
and how can i limit the result to 5 users only?
i cannot use limit on that select.
thanx
Use array_unique() and then array_slice(). -
$arr = array(
-
1, 1, 2, 2, 3, 3, 4, 4, 5, 5
-
);
-
-
print_r(array_slice(array_unique($arr), 0, 4));
-
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: - $sqlhis="select * from bidding_details where bid_id=$bid_id and sortbid = '1' order by bid_price desc ";
-
$queryhis=mysql_query($sqlhis);
-
-
while ($rowhis=mysql_fetch_array($queryhis)){
-
$username=$rowhis['username'];
-
$arr = array(
-
$username
-
);
-
-
}
-
-
$arr=(array_slice(array_unique($arr), 0, 5));
-
-
echo $arr[0] . "<br />";
-
echo $arr[1] . "<br />";
-
echo $arr[2] . "<br />";
-
echo $arr[3] . "<br />";
-
echo $arr[4] . "<br />";
any idea , im new in this php world :)
thanx
use
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.
thanx alot man ,that fixed my work!! tahnx to all that helped !!!
it's perfect :)
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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"...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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
|
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...
|
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...
|
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...
|
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...
|
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,...
| |