title: UPDATE pivoted table to DB
body: <p>I have a pivoted table from a MySQL query that was derived from:</p>
  
  <pre><code>+------------+------------+-----------------+------------------+------------+-----+
  |submit_time |form_name   |field_name       | field_value      |file_order  |file | 
  +------------+------------+-----------------+------------------+------------+-----+
  |15052703120 |Submissions |your-name        | Leonard Chia     |9999        |file | 
  +------------+------------+-----------------+------------------+------------+-----+
  |15052703120 |Submissions |your-email       | leonard@mail     |8           |file | 
  +------------+------------+-----------------+------------------+------------+-----+
  |15052703120 |Submissions |status           | Pending Start    |9           |file | 
  +------------+------------+-----------------+------------------+------------+-----+
  |15052703120 |Submissions |location         | DD1 Classroom    |7           |file | 
  +------------+------------+-----------------+------------------+------------+-----+
  </code></pre>
  
  <p>to this:</p>
  
  <pre><code>+-------------+-------------+-----+--------------+---------------+
  | Requestor   | Email       |ETC. |Location      | Status        |
  +-------------+-------------+-----+--------------+---------------+
  |Leonard Chia | leonard@mail|ETC. |DD1 Classroom | Pending Start |
  +-------------+-------------+-----+--------------+---------------+
  |Sng Yeekia   | yeekias@mail|ETC. |DD2 Classroom | Pending Spare |
  +-------------+-------------+-----+--------------+---------------+
  |Gabriel Lee  | gabriel@mail|ETC. |SL1 Classroom | Completed     |
  +-------------+-------------+-----+--------------+---------------+
  </code></pre>
  
  <p>The table is achieved using a wpDataTables plugin which provides me a shortcode for the table to be displayed on my webpage. The query used to extract the data is as such:</p>
  
  <pre><code>SELECT
      submit_time,
      MAX(IF(field_name = 'your-name',     field_value, NULL)) AS Requestor,
      MAX(IF(field_name = 'campus',        field_value, NULL)) AS Campus,
      MAX(IF(field_name = 'location',      field_value, NULL)) AS `Defect Location`,
      MAX(IF(field_name = 'your-message',  field_value, NULL)) AS `Defect Description`,
      MAX(IF(field_name = 'menu-priority', field_value, NULL)) AS Priority,
      MAX(IF(field_name = 'work-done',     field_value, NULL)) AS `Action Taken`,
      MAX(IF(field_name = 'assigned-to',   field_value, NULL)) AS `Assigned To`,
      MAX(IF(field_name = 'category',      field_value, NULL)) AS Category,
      MAX(IF(field_name = 'file-photo',    field_value, NULL)) AS Photo
      MAX(IF(field_name = 'status',        field_value, NULL)) AS Status
  FROM
      wpc5_cf7dbplugin_submits
  GROUP BY
      submit_time
  </code></pre>
  
  <p>The plugin allows users to edit the table in the frontend. Issue comes when I tried to edit any value on the table via the frontend table, there is an error prompted and values are not updated.</p>
  
  <p>The error returned is <code>ERROR Unknown column 'Requestor' from the field_list</code>. I'm guessing that the DB doesn't recognize the column headers since they've been pivoted.</p>
  
  <p>Am seeking for ideas or workarounds on how I can solve this issue. Any help would be appreciated.</p>