title: How to edit and insert dynamicaly created form textboxes values to MySQL DB?
body: <p>I'm having a bunch of features table in MySQL DB in my PHP project. I'm fetching through php and creating a table with textboxes named by column name and id of record in photos table using code:</p>
  
  <p><code>functions.php</code> Code:</p>
  
  <pre><code>function m_html_editPhotos($id) {
  $result = "&lt;table class=\"tabelka\" id=\"tbl_photos\"&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Miniaturka&lt;/th&gt;&lt;th&gt;Duże zdjęcie&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;";
  $mysqli = m_db_Init();
  $qry = "SELECT ID, Img_Min, Img_Nrm FROM tbl_Zdjecie WHERE ID_Grzyb = ?";
  if($stmt = $mysqli -&gt; prepare($qry)) {
            $stmt -&gt; bind_param("i", $id);
            mysqli_stmt_bind_result($stmt, $img_id, $img_min, $img_nrm);
            $stmt-&gt;execute();
            $i =0;
            while (mysqli_stmt_fetch($stmt)) {
                $i = $i+1;
                $result .= "&lt;tr&gt;&lt;td&gt;&lt;!--&lt;label&gt;Link do miniaturki:&lt;label&gt;--&gt;&lt;input type=\"text\" class=\"required\" name=\"photo[$i][min]\" value=$img_min&gt;&lt;/td&gt;&lt;td&gt;&lt;!--&lt;label&gt;Link do zdjęcia pełnego rozmiaru:&lt;/label&gt;--&gt;&lt;input type=\"text\" class=\"required\" name=\"photo[$i][nrm]\" value=$img_nrm&gt;&lt;/td&gt;&lt;td style=\"display:none;\"&gt;&lt;input type=\"text\" name=\"photo[$i][id]\" value=$img_id /&gt;&lt;/td&gt;&lt;/tr&gt;";
            }
            $stmt -&gt; close();      
  }
  mysqli_close($mysqli);
  $result .= "&lt;/tbody&gt;&lt;/table&gt;&lt;div class=\"link\" onclick=\"AddPhotoEditRow();\"&gt;Dodaj kolejne zdjęcie&lt;/div&gt;";
  return $result;
  }
  </code></pre>
  
  <p>Now what I'd like is to edit photos table iterating through each row of generated as above table with textboxes for thumbnail_url (<code>img_min</code>) and full size link (<code>img_nrm</code>)
  Additionally I'd like to add new ones to the table from dynamically created rows by function AddPhotoEditRow(); </p>
  
  <p><code>functions.js</code> Code:</p>
  
  <pre><code>function AddPhotoEditRow(){
   $('#tbl_photos &gt; tbody:last').append('&lt;tr&gt;&lt;td&gt;&lt;input type="text" name="photo[0][min]"&gt;&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="photo[0][nrm]"&gt;&lt;/td&gt;&lt;td style=\"display:none;\"&gt;&lt;input type=\"text\" name=\"photo[0][id]\" value=\"0\" /&gt;&lt;/td&gt;&lt;/tr&gt;');
  }
  </code></pre>
  
  <p><code>edit.php</code> Code:</p>
  
  <pre><code>include 'functions.php';
  if(isset($_POST["change"])) m_db_updateAllFeatures($_GET["id"]);
  if (m_db_isAdmin("")){
  if (!isset($_GET["id"]) || !is_numeric($_GET["id"]))
      header("Location: ../index.php");
  else {
  if (isset($_POST["Nazwa_PL"]))
      m_db_UpdateName("PL", $_GET["id"],$_POST["Nazwa_PL"]);
  if (isset($_POST["Nazwa_Lac"]))
      m_db_UpdateName("Lac", $_GET["id"],$_POST["Nazwa_Lac"]);
  render_edit_body();
      }
  }
  </code></pre>
  
  <p>I'd like to iterate somehow through photos links and update existing records by parsing textbox names passed through $_POST, additionally would be good to insert new photo links (that with id=0). I'm setting new rows' id to 0 because I need to distinguish if I'm inserting to table, or updating, right? I've assumed that all <code>0</code>-indexed fields should be added, rest of them should be inserted. I might have my conception wrong, if there is a better way to do full functionality to that table "control" then I'm very open to suggestions.</p>