Hi,

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

I'm selecting the columns from a certain table:

<?php
    $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

<?php
    $values[]="";

    if($_GET['action']=='update')
    {
        $selectTableResult=$dbConnect->query("SELECT *
                                              FROM ".$table."
                                              WHERE `ID`=1");

        while($rowTable=$selectTableResult->fetch_assoc())
        {
            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] ?>">
</div>

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?

Thanks!

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
$_POST['textBox'][$myid]

commented: nice one +4