Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3982156
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:29:42+00:00 2026-05-20T05:29:42+00:00

In the query I have order by name (alphabetically), stick the query in $res,

  • 0

In the query I have order by name (alphabetically), stick the query in $res, and then loop over the results.

while($rs = mysql_fetch_assoc($res)){
    echo $rs['name'];
}

Now in that while loop there is a “webmaster” name. I need to take “Webmaster” and place it at the end of the loop (so it echoes out last) or place “Webmaster / Affiliate ProgramsWebshops” in $res (at the end of the query before hitting the while loop.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T05:29:42+00:00Added an answer on May 20, 2026 at 5:29 am

    easiest way would be to edit your query and change the ordering from:

    ORDER BY
      name
    

    to

    ORDER BY
      IF(name LIKE 'webmaster',1,0),
      name
    

    note: this IF is mysql-syntax – you havn’t posted wich database you’re using. on postgres it would be something like (not 100% sure):

    ORDER BY
      CASE WHEN name ILIKE 'webmaster' THEN 1 ELSE 0 ,
      name
    

    EDIT to explain this: by changing the order this way, it’s like putting an additional column to the ordering that contains 1 if the name is “webmaster” or 0 in every other case. by ordering by this “column” first, the “webmaster” is always at the end (or: all “webmaster”s – if there are more than one)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a query: select event_type, department_name, effective_time, row_number() OVER (PARTITION BY event_type,department_name ORDER
I have this query which groups the results by ORDER#. SELECT ORDER#, MAX(SHIPDATE -
I have this mysql query. Any ideas how to order the results in order
I have the following query: select top 100 eid, cid, id, position, ROW_NUMBER() over(order
Right now I have one query that returns a list of results and displays
I have a mysql query Select * from tbl_schoolphotos where Filename like 'glasshouse_1_%' order
I have problem with SQL query. If given order contains items, witch does not
I have a MySQL query SELECT * FROM 'redirect' WHERE 'user_id'= \''.$_SESSION['user_id'].' \' ORDER
I need to used dynamic order query in mysql and i have successfully achieved
I have a query that I want to sort alphabetically, but the trick is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.