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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:37:31+00:00 2026-06-07T00:37:31+00:00

I would like to alter two different tables from an HTML post request to

  • 0

I would like to alter two different tables from an HTML post request to a server running PHP. Before, when I only wanted to alter one table, all the columns and values were put into the POST array, so I would have [colname1]=>val1, [colname2]=val2, etc. I would then loop through the POST to build the correct MySQL statement to run the query.

I’ve modified my code so that depending on what drop down box is selected, not only will the first table get modified, but another table (of the users choice) will get modified as well. So ideally I would like the POST variable in PHP to have an array of arrays. So in the end, it would be nice if the POST variable looked like this…

[mainTable][colnam1]=>val1 [colnam2]=>val2
[otherTable][colnam1]=>val1 [colnam2]=>val2

My current workaround is having to give the table name in front of the the form input name and then parsing it on the server, but I would rather be more flexible and not do it this way.

<input type="text" name="mainTable_colname">
<input type="text" name="otherTable_colname">

From my understanding of using forms and POST, only the named html form elements will be passed up into the post variable.

Does anyone know a better way of doing this?

  • 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-07T00:37:34+00:00Added an answer on June 7, 2026 at 12:37 am

    Specify the name attribute of your elements to be arrays, including the keys you want, and you’ll get arrays in $_POST:

    <input type="text" name="mainTable[colname]">
    <input type="text" name="mainTable[colname2]">
    <input type="text" name="otherTable[colname]">
    

    A var_dump( $_POST['mainTable']); would yield something similar to:

    array( 'colname' => 1, 'colname2' => 1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using ActiveRecord in Rails 3 to pull data from two different tables
I have two different tables trackingevent and link Trackingevent looks like eventName|eventStamp SHARE_FACEBOOK|2011-01-20 14:05:40
I would like to make a view , and in that view alter the
I would like to apply a css file after choosing an option from a
I'm using MS SQL Server 2008, and I would like this: +------+--------+--------+------------+ | id
I am getting responses from two different web services in XML format. Both web
I have two tables representing two different types of imagery. I am using PostGIS
I have two tables like this: CREATE TABLE table1_lang ( id serial NOT NULL,
I have a WCF service with many methods. I would like that after executing
I have a NSThread that i would like to timeout after a certain amount

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.