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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:05:47+00:00 2026-06-15T21:05:47+00:00

I would like to update multiple MySQL records from the same table, using only

  • 0

I would like to update multiple MySQL records from the same table, using only one submit button.

Here is a simple version of the code that I am using to generate the form:

<form action='' method='post'> 
    <?php 
    $sql = "SELECT TagName, TagID FROM tags";
    $result = mysql_query($sql) or die ($sql. '-error' .mysql_error());

    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        echo "<input type='text' name='TagField' value='".$row['TagName']."'>";
    }
    ?>
    <input type="submit" name="tag_edit_submit" value="Edit">
</form>

What sort of UPDATE query could I use? I can’t seem to figure out the correct combination of arrays/loops to make it happen. Please let me know if you require more information.

  • 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-15T21:05:48+00:00Added an answer on June 15, 2026 at 9:05 pm

    You can carry the tagIds with the tag names in the form. I assume tagIds count and tagNames count are identical.

    <form action='' method='post'> 
        <?php 
        $sql = "SELECT TagName, TagID FROM tags";
        $result = mysql_query($sql) or die ($sql. '-error' .mysql_error());
    
        while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
            echo "<input type='hidden' name='TagIDs[]' value='".$row['TagID']."'>";
            echo "<input type='text' name='TagNames[]' value='".$row['TagName']."'>";
        }
        ?>
        <input type="submit" name="tag_edit_submit" value="Edit">
    </form>
    
    
    <?php 
    $p=$_POST;
    if( isset($p['TagNames']) && is_array($p['TagNames'] )) {
    
      foreach($p['TagNames'] as $key=>$name){
    
        $tagId= $p['TagIds'][$key];
    
        // validate and clean up sql injections from $tagId and $name
    
        $sql='update tags set TagName="'.$name.'" where TagID=".$tagId." limit 1';
        // execute the query
      }
    
    } 
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to update multiple records in a MySQL table using a single
I would like to submit information to a mySql database using php and ajax.
I would like to update 3 rows of a single table, with different values
I would like to update an xml file from another xml file.I have used
I would like to update one of the variables in a vector layer class
I'm using hadoop to update some records in a mysql db... The issue that
I'm new to MySQL. I'm using this to update multiple rows with different values,
I would like to update (change the content) some part of the webpage without
I would like to update the Diagnostic configuration file for the azure roles whenever
I would like to update my current SB2 theme Sunburst so that the current

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.