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 6664723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:38:34+00:00 2026-05-26T02:38:34+00:00

I’m stuck on something that I can’t fix by myself :( Unfortunately… I need

  • 0

I’m stuck on something that I can’t fix by myself 🙁 Unfortunately… I need to store a rank from some inputs fields generated by jQuery in my TABLE, let me explain :

When I click on a button I add an input field in my page, each input field generated have an incremented name (name0, name1 …) and an incremented id (item-1, item-2 and so on)

I use the sortable function of jQuery and everything is okay, I drag and drop my fields and they have their order.

I serialize everything and it gives me that : item[]=0&item;[]=2&item;[]=1&item;[]=3 each field have a rank. Well now I need to store this rank in my DB WITH the field associated (my TABLE look like this : ‘id’ ‘rank’ the ‘id field is auto incremented)

Here’s my code :

THE JS FUNCTION TO ADD FIELDS :

$(function() {

 var item = 'item-';
 var i = 0;
 var k = 0;
 var deletebtn = "<div id='deletebtn'>delete this</div>";

 $("#button_add").live("click", function(){
   $('#reorder').append("<li id="+ item + i++ +" class='list_item'>" + "<input type='text' name='title"+ k++ +"' value='' kind='title' />" + deletebtn + "</li>");
 });
}); 

TO GET THE SERIALIZE RESULT :

newRank = $("#reorder").sortable("serialize");
 $("#rank").val(newRank); 

This is linked to an input field to get the serialized value

<input type="hidden" id="rank" name="rank" value="" />

THE PHP TO $_POST THE INPUT FIELD :

    $rank = $this->input->post('rank'); 

// THIS WILL GIVE ME THE RESULT : item[]=0&item;[]=2&item;[]=1&item;[]=3

Any idea to store the rank of each field corresponding to their id in my DB ? Any help would be very very appreciated !!

  • 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-26T02:38:34+00:00Added an answer on May 26, 2026 at 2:38 am

    If I’m understanding you correctly, you could of course create an array from $rank and loop through for your db inserts:

    $ranks = explode("&", $rank); // gives an array 
    
    foreach ($ranks as $r)
    {
        // you'll have to do some string manipulation here
        $num = str_replace("item[]=", "", $r);
    
        // $num should now be a number - add it to your db below
        // ...
    }
    

    There are some extra semi-colons in your $rank, but not sure if that is a typo or not.

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

Sidebar

Related Questions

I feel that it should be something very simple and obvious but just stuck
I'm trying to self-teach myself C++, and once again I got stuck on something
I am new to js and a bit stuck (with something that is probably
I'm stuck in something that I'm sure rather easy I have a field in
I am stuck with something quite simple but really annoying: I have an xml
I'm kinda stuck with something which must be appalingly simple. I'm trying to write
Use case: A does something on his box and gots stuck. He asks B
I'm a bit stuck on this. Basically I want to do something like the
I think I have a basic understanding of REST, but something I'm stuck on
Being stuck with a legacy database schema that no longer reflects your data model

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.