title: create a form edit function php
body: <p>I created a function to display the content of a table. This is the function:</p>
  
  <pre><code>function query_tabel ($sql){
      $query = $sql;
      $result = mysql_query($query);
      $kolomen_tellen = mysql_num_fields($result);
      if (!$result) {
          die("Error Query: " . mysql_error());
      }
      print "&lt;table border=1&gt;\n";
  
          print "&lt;tr&gt;";
              for ($column_num = 0; $column_num &lt; $kolomen_tellen; $column_num++)
              {
                  $fieldname = mysql_field_name($result, $column_num);
                  print "&lt;TH&gt;$fieldname&lt;/TH&gt;";
              }
              print "&lt;/tr&gt;";
  
      while ($row = mysql_fetch_row($result)) {
          print ("&lt;TR&gt;");
          for     ($column_num = 0; $column_num &lt; $kolomen_tellen; $column_num++)
              print ("&lt;TD&gt;$row[$column_num]&lt;/TD&gt;\n");
          print ("&lt;/TR&gt;\n");
      }
      print "&lt;/table&gt;";
  </code></pre>
  
  <p>it work and can call the function any time in any file.
  But I want another function that creates an edit form with input fields.</p>
  
  <p>This is my first draft:</p>
  
  <pre><code>function query_tabel_edit ($sql, $filename){
      $query = $sql;
      $result = mysql_query($query);
      $kolomen_tellen = mysql_num_fields($result);
      if (!$result) {
          die("Error Query: " . mysql_error());
      }
      print "&lt;table class=edit&gt;\n";
  
          print "&lt;tr&gt;";
              for ($column_num = 0; $column_num &lt; $kolomen_tellen; $column_num++)
              {
                  $fieldname = mysql_field_name($result, $column_num);
                  print "&lt;TH class=edit&gt;$fieldname&lt;/TH&gt;";
              }
              print "&lt;/tr&gt;";
  
      while ($row = mysql_fetch_row($result)) {
          print "&lt;form action=$filename method=post&gt;";
          print ("&lt;TR&gt;");
          for     ($column_num = 0; $column_num &lt; $kolomen_tellen; $column_num++)
              print ("&lt;TD class=edit&gt; &lt;input class=edit type=text name=$row[$column_num] value=$row[$column_num] &lt;/TD&gt;\n"); 
              print ("&lt;TD class=edit&gt; &lt;input class=edit type=submit name=update value=edit&gt; &lt;TD&gt;\n");
          print ("&lt;/TR&gt;\n");
      }
      print "&lt;/table&gt;";
  }
  </code></pre>
  
  <p>So I added the edit link, works like a charm but how and where do I create and put the SQL line that modify the record.?</p>
  
  <p>Any idea how to create this edit sql statement and do I need to put data sql line somewhere in my function or in the PHP file that calls the function?</p>