I want to create a dynamic form, relative with the table i'm working with.

I'm selecting the columns from a certain table:

    $tableColumns = $dbConnect->query("SHOW COLUMNS
                                       FROM projects 
                                       WHERE Field NOT IN ('ID');");

Then i want to get each result's value (according to the ID selected) and put it in an array:
URL: localhost/index.php?page=form&action=update&id=1


        $selectTableResult=$dbConnect->query("SELECT *
                                              FROM ".$table."
                                              WHERE `ID`=1");

            print_r($values[] = $rowTable);

What i want to do is write something like this:

<div class="form-group">
    <label>Text Input</label>
    <input class="form-control" name="textBox" type="text" value="<?php echo $value[1] ?>">

Like this, if i want to update an Item, the value of the input is "Test" (or whatever) and if i want to add an Item the value is empty.

Can someone help me, please?


You could let Ajax do this. You would then repeat certain PHP function over and over again, with space of around 2 seconds, wait until PHP finds something new in the database and produces output, and then create a new field (with JavaScript) and make it's content, the content that PHP has provided you.

<input name="textBox[<?php echo $myid; ?>]"

when you post this you'll get an array for each form element with key = id

commented: nice one +4