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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:12:31+00:00 2026-06-06T03:12:31+00:00

I have a dynamic rows coming from the database. each row has an order

  • 0

I have a dynamic rows coming from the database. each row has an order field. I want to make the user able to change the order by entering the order in text boxes show’s next to each row, and when the user click save each row will be updated with the new order.

My problem is when I wrote this code:

    <table>
    <?
    foreach($results as $p)
    {
        echo '
            <tr>
            <td>'.$p['page_title'].'</td>
            <td><input type="text" size="2" id="'.$p['page_id'].'" name="s[]" value="'.$p['menu_order'].'"></td>
        </tr>';
    }
    ?>
    <tr><td colspan="2"><input type="submit" value="Save Order"></td></tr>
    </table>

as you can see that every dynamic text box would give the the new order after posting the form, but the Question is how I can know this order to which row ?

the image would explain more. After I clicked Save the s array would be like this:

Array ( [0] => 2 1 => 3 [2] => 1 )

However, I cannot know the page that I want to update !!
enter image description here

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

    I think what you are asking is how to order the fields by the number assigned to it. If that’s what you are looking to do and if you are using MySQL to store this data you can just retreive it in that order. For example:

    SELECT * FROM mytable ORDER BY menu_order ASC
    

    Edit: Now that I have re-read your question you also might be asking how to assign that order to each row. I noticed that your fields are named s[] You could name them $p['page_id'] and update them accordingly.

     <?
        foreach($results as $p)
        {
            echo '
                <tr>
                <td>'.$p['page_title'].'</td>
                <td><input type="text" size="2" id="'.$p['page_id'].'" name="s['.$p['page_id'].']" value="'.$p['menu_order'].'"></td>
            </tr>';
        }
        ?>
    

    And then

    foreach($_POST['s'] as $key => $value) {
        // Update each $key with $value
        // Where $key is the ID and $value is the order
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a datatable where the rows are dynamic and each row contain a
I have a dynamic datatable, created from a database. I want to add a
I have a dynamic text file that picks content from a database according to
I want to have a dynamic table, with rows added over time as a
I have this table where I can generate dynamic rows (which has input <type=text
I have a dynamic gridview, about 35 rows by 11 columns. When the user
I have a dynamic form where rows are added and removed using JavaScript. From
Hi i have a table and i want to add dynamic rows to that
I have a a gridview with a dynamic number of columns and rows. In
I have dynamic array filled with bytes, which are read from .raw file with

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.