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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T05:55:26+00:00 2026-05-25T05:55:26+00:00

Assume I have some data from the database and store in a array, which

  • 0

Assume I have some data from the database and store in a array, which like this:

$testArray = array(
    array('0', 'name1', 'status1'),
    array('1', 'name2', 'status2')
);

and I can print the content of the array as a html table, like this way:

Id  name    status
0   name1   status1 
1   name2   status2 

I want to use a ‘status’ dropdown list at the end of each row to change the status of each entry, and update into the database table. My questions are:
How do I get the row id of each row(the ‘Id’ column) when I select a option of the drodown list?
How to pass these info to the backend inorder to update the database table? I guess it should use some javascript. And below is the code:

<?php

$testArray = array(
    array('0', 'name1', 'status1'),
    array('1', 'name2', 'status2')
);
?>

<html>
    <head>   
    </head>
    <body>
        <table>
            <tr>
                <td>Id</td>
                <td>name</td>
                <td>status</td>
            </tr>
            <?php
            for ($i = 0; $i < count($testArray); $i++){
                echo '<tr>';
                for ($j = 0; $j < count($testArray[$i]); $j++){
                    echo '<td>';
                    echo $testArray[$i][$j];
                    echo '</td>';
                }
                echo '<td>';
                echo '<select>';
                echo "'<option value='0'>status1</option>";
                echo "'<option value='1'>status2</option>";
                echo '</select>';
                echo '</td>';
                echo '</tr>';
            }
            ?>
        </table>
    </body>
</html>

Thanks for help!

  • 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-25T05:55:26+00:00Added an answer on May 25, 2026 at 5:55 am

    You Could:

    1. Give each of your select’s an id that correspond to the row of data.

    2. On change(jQuery), Get the value of the select, and use the jquery ajax call to send the rowID, and the ‘StatusValue’ to the handling page.

    3. Show an status message on return of data.

    http://api.jquery.com/jQuery.ajax/

    –Building the Select

    <?php
                for ($i = 0; $i < count($testArray); $i++){
                    echo '<tr>';
                    for ($j = 0; $j < count($testArray[$i]); $j++){
                        echo '<td>';
                        echo $testArray[$i][$j];
                        echo '</td>';
                    }
                    echo '<td>';
                    **echo '<select id="' + $testArray[$i][0] + '">';**
                    echo "'<option value='0'>status1</option>";
                    echo "'<option value='1'>status2</option>";
                    echo '</select>';
                    echo '</td>';
                    echo '</tr>';
                }
    ?>
    

    –The jQuery (you will need the jquery file, download from jquery.com)

    $(document).ready(function(){
        $('select').change(function () {
            var rowIdVal = $(this).attr('id');  // the id of the select (your rowID)
            var statusVal = $(this).val();  // the value of the select
    
            // post id to the server using ajax (you can use jQuery ajax request)
            ////I would check if the values are valid and not null...
            $.ajax({
               type: "POST",
               url: "YOURHANDLERFILE.php",
               data: {status: statusVal, rowId: rowIdVal},
               success: function(d){     
                    //show a status message     
               }
             });
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assume you have some objects which have several fields they can be compared by:
Assume I have the following input in Pig: some And I would like to
Assume I have a function template like this: template<class T> inline void doStuff(T* arr)
Problem: I have an address field from an Access database which has been converted
Assume we have a method like this: public IEnumerable<T> FirstMethod() { var entities =
I have an application that is scheduled and get some data from a another
In my app, I frequently fetch some data from database, serialize it automatically and
Assume some domain and view objects (that have no common base class) public class
Assume I have a class foo, and wish to use a std::map to store
I'm trying to fix some errors on a big database of stock exchange data.

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.