473,385 Members | 1,640 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,385 software developers and data experts.

order a variable to display from the highest to the lowest

123 100+
my code below will echo the position of the user if the number($nm) fallbetween the range so let say i have $nm = 10,4,3,3,1 respectively the position will be(staff,staff,staff,marketer,staff) instead of(marketer,staff,staff,staff,staff) how can i arrange so that marketer come first(marketer,staff,staff,staff,staff).

Expand|Select|Wrap|Line Numbers
  1. $query = "SELECT DISTINCT username,num FROM user ORDER BY num DESC LIMIT 5";
  2. $result = mysql_query ($query) or die('query error');
  3. while( $line = mysql_fetch_assoc($result)){
  4.  
  5. $um = $line[username];
  6. $nm = $line[num];
  7.  
  8. echo "name:$um";
  9.  
  10. if($nm <= 50){
  11. echo "Position: president";
  12. }else if($nm <= 40){
  13. echo "Position: vice";
  14. }else if($nm <= 30){
  15. echo "Position: manager";
  16. }else if($nm <= 20){
  17. echo "Position: marketer";
  18. }else if($nm <= 10){
  19. echo "Position: staff";
  20. }
Aug 23 '11 #1
1 1789
Rabbit
12,516 Expert Mod 8TB
Actually, according to your code, everyone would be a president unless they have a num larger than 50.

But that aside, you have a num of 3 that is assigned two positions in your example. That makes no sense.
Aug 23 '11 #2

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

Similar topics

4
by: danubian | last post by:
Hi, I'm a newbie in php/mysql programming,really am. I'm working on a web-site that allows registration and posterior logging in. Already registered user logs in with valid username and...
1
by: Smriti Dev | last post by:
Hi, I have a drop down menu with a listing of communities and I use it to select a community, selecting a letter ie. "T" , I get bumped to the "T" section to choose communities that start with...
4
by: Joe User | last post by:
Hi all....I have a feeling this is going to be one of those twisted query questions, but here it goes anyways.... I want to generate a report that shows the chronology of events (represented by...
5
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, Recently, I just found out that our program behaves differently from before. in our asp, in order to prevent data disppearing problem in form fields,we use session variable to display...
9
by: tanyali | last post by:
How to set up the environment variable DISPLAY in Linux : 1- Redhat 2- SuSe I used : export DISPLAY=donner:0.0 donner is the domain name. it said : you must specify the...
2
by: Sbudah | last post by:
I got my away around this - how do I delete this post? Hi all, I have a table with values similar to this: 110 1000 9000 980 20000
2
by: ubohra | last post by:
Hii all, Need your help!! I am got stuck into a problem that we have a application where there are some pages to display some courses which the user will take. I have to change the order of that...
1
by: niner | last post by:
I have been working on the following code for about 6 hours now. I am attempting to write a program in Java that finds the highest, lowest, sum, and mean of an array. The program should also end...
1
by: Kris tarun | last post by:
I have a table of a retail store which has almost 13000 customers. and i want to write a query for this.. Group products based on their sales patterns. Highest, lowest, and median values. Use...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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:
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...
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...

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.