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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:22:25+00:00 2026-05-16T21:22:25+00:00

I have a question regarding the creation of Auto Dynamic text boxes within PHP.

  • 0

I have a question regarding the creation of Auto Dynamic text boxes within PHP. The scenario is like this:

  • I have 2 tables in a MySQL database.
  • The 2 tables (students/teachers) have different number of fields
  • Teachers = 8 fields / Students = 5 fields
  • A page for inserting new data into the tables is created.

So now there is a need to allow the “insert” page to auto generate the number of fields found within the table to allow inserting of data instead of creating 2 different PHP pages for the website.

I think that by including array into <input type="text" name="TableFieldArray[]" size="40" maxlength="256"> can be used to auto generate the number of fields needed for the insertion of the new data.

Anybody can give me some suggestions?

  • 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-16T21:22:26+00:00Added an answer on May 16, 2026 at 9:22 pm

    adapted from example #1 on this page in the php manual:

    <?php
    $result = mysql_query("SHOW COLUMNS FROM Teachers");
    if (!$result) {
        echo 'Could not run query: ' . mysql_error();
        exit;
    }
    if (mysql_num_rows($result) > 0) {
        while ($row = mysql_fetch_assoc($result)) {
            echo "<label for=\"ff-{$row['Field']}\" >{$row['Field']}</label>";
            echo "<input id=\"ff-{$row['Field']}\" type=\"text\" name=\"{$row['Field']}\" size=\"40\" maxlength=\"256\" />";
        }
    }
    

    That will give you one <input> element for each column in the Teachers table. The input elements will be named the same as their corresponding mysql columns.

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

Sidebar

Related Questions

I have a quick question regarding the creation of absolute URLs within a symfony
I have a question regarding the creation of a utility that executes another command.
I have a question regarding the proper way to modify a php DateTime object.
I have a question regarding the best practise of handling formated text when using
I have a question regarding a race condition scenario. The question: Consider the following
I have a question regarding implementation of smart-search features. For example, consider something like
I have question regarding polymorphism about its assignment statement, for Example this is The
I have a question regarding inheritance in Java. If I have this base class
i have one question regarding creation of divs: I have button, when user clicks
I have the following question regarding Sitecore item creation: Given the following content tree:

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.