Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to build a dynamic MySQL INSERT statement with PHP
    primarykey
    data
    text
    <p><strong>Hello</strong><br /><br /> This part of a form is showing columns names from mysql table (names of applications installed on a computer) and creating a form with YES/NO option or input type="text" box for additional privileges to a application.. <br /><br /> How can I insert it back to a mysql table using POST and mysql_query INSERT INTO????? <br /> Quantity of columns is changing because there is another form for adding applications with/without privileges.. </p> <pre><code>&lt;tr bgcolor=#ddddff&gt;'; //mysql_query for getting columns names $result = mysql_query("SHOW COLUMNS FROM employees") or die(mysql_error()); while ($row = mysql_fetch_array($result)) { //exclude these columns bcs these are in other part of form if($row[0] == 'id' || $row[0] == 'nameandsurname' || $row[0] == 'department' || $row[0] == 'phone' || $row[0] == 'computer' || $row[0] == 'data') continue; echo '&lt;td bgcolor=#ddddff&gt;'.$row[0].'&lt;br /&gt;'; if (stripos($row[0], "privileges") !== false) { echo '&lt;td bgcolor=#ddddff&gt;&lt;p&gt;&lt;a class=hint href=#&gt; &lt;input type="text" name="'.$row[0].'"&gt; &lt;span&gt;Privileges like "occupation" or "like someone"&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;'; } else { echo '&lt;td bgcolor=#ddddff align=center&gt;&lt;select name="'.$row[0].'"&gt; &lt;option value = "No"&gt;No &lt;option value = "Yes"&gt;Yes &lt;/td&gt; &lt;/tr&gt;'; } } trim($_POST); // ???? $query = "INSERT INTO 'employees' VALUES (??)"; // ???? </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload