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

  • Home
  • SEARCH
  • 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 8812735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:40:20+00:00 2026-06-14T03:40:20+00:00

I am a complete PHP/MySQL newb and would really appreciate some help storing the

  • 0

I am a complete PHP/MySQL newb and would really appreciate some help storing the position of each value in an array to the appropriate DB table column. The value itself in the array corresponds to a column in the DB table.

In my php form processing page I have the array $rankArray, where each value corresponds with a column in my database table. What I want to do is save the position of of each value to its corresponding column. For example, if

$rankArray = [2,5,3,4,1]

it should store ‘1’ in column 2, ‘2’ in column 5, ‘3’ in column 3, etc.

  • 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-06-14T03:40:21+00:00Added an answer on June 14, 2026 at 3:40 am

    I would do something like:

    $rankArray = [2,5,3,4,1];
    $flipped = array_flip($rankArray);
    ksort($flipped);
    

    Now flipped should be an array in this order: [5,1,3,4,2] and your values can be inserted into the correct columns.

    This works because array_flip returns an array where the keys and values are flipped, then ksort makes sure the array keys are sorted.

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

Sidebar

Related Questions

I am building my first PHP/MySQL site and i would like to return search
I need to be able to temporarily store a complete PHP object (containing some
I'm going to teach PHP (plus HTML, plus MySQL) to a complete beginner. What
We are currently running an ajax auto complete script through mySQL, as such: <?php
I need a little help here getting data from mysql via PHP with AS3.
Need help with PHP Mysql code to insert multiple select data into database. With
I am forking some php scripts and I need to update a mysql row
I'm a complete mySQL & PHP noob, and in my table, whenever there is
I am a complete newbie to php curl . Can anyone tell me where
I am borrowing a complete eCommerce website with backend(admin) interface built in PHP from

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.