I have a MySQL table with the following format:
Task_ID
Op_ID
Op_Desc
Each task can have up to 6 Operations,
I have used the following code to select the Op_Descs (ordered by Op_ID), and can get the form to display the Operations.
   <!DOCTYPE html>
  <?php
    require 'conn.php';
  $id = 1; /* In live situation this would be picked up from $_SESSION */
  $used = 0;
  $desc = array();
  $original = array();
  if ($used == 0) {
      $query = $conn->query("SELECT `desc` FROM `test` WHERE id = 1 ORDER BY `subid`") or die(mysqli_error($conn));
    while ($row = mysqli_fetch_array($query)) {
        echo $row['desc'];
        echo "<br />";
        $desc[] = $row['desc'];
        /* $original will be used to see if data has changed for saving back to MySQL table */
        $original[] = $row['desc'];
    }
    $used = 1;
}
?>
<html>
  <head>
    <meta charset="UTF-8">
    <title></title>
  </head>
  <body>
    <form class="form-horizontal" value = "POST" action="#">
        <input id="one" name="one" value="<?php echo $desc[0] ?>" type="text">
        <input id="two" name="two" value="<?php echo $desc[1] ?>" type="text">
        <input id="three" name="three" value="<?php echo $desc[2] ?>" type="text">
        <input id="four" name="four" value="<?php echo $desc[3] ?>" type="text">
        <input id="five" name="five" value="<?php echo $desc[4] ?>" type="text">
        <input id="six" name="six" value="<?php echo $desc[5] ?>" type="text">
        <input type="submit" value="submit">
      </form>
  </body>
.</html>
I have tried to use an if (isset($_POST…) construct to check the form output against the $original array elements, so only need to update those that have changed.
However I haven’t been able to get this to work, and am wondering if anyone can point me in the correct direction?
