title: MySQL Update with PHP not working how i wanted it to
body: <p>Hi this is my first post so please excuse any errors </p>
  
  <p>Background if this helps 
  i've created several pages for a website 
  submit form - puts data in to database - all working ok 
  summary page - pulls through elements of database - all working ok 
  edit page - this is where my problem is </p>
  
  <p>my problem 
  when creating a edit page it does not pull through the updated variable from the form and just updates the database with a empty field</p>
  
  <p>so here is the code </p>
  
  <p>edit.php </p>
  
  <pre><code>// Create connection
  $conn = new mysqli($servername, $username, $password, $dbname);
  // Check connection
  if ($conn-&gt;connect_error) {
  die("Connection failed: " . $conn-&gt;connect_error);
  }
  
  $var_value = $_GET['id'];
  
  $result = $conn-&gt;query($sql);
  
  if ($result-&gt;num_rows &gt; 0) {
  // output data of each row
  while($row = $result-&gt;fetch_assoc()) { 
  ?&gt;
  &lt;form action="/update.php" method="post"&gt;
  &lt;label&gt;Property Title
  &lt;input type="text" name="title" value="&lt;?php echo $row[title]?&gt;" /&gt;
  &lt;form method='get' action='update.php'&gt;
  &lt;input type='hidden' name='id' value= "&lt;?php echo $row[id]?&gt;" &gt;
  &lt;input type='submit' class='button radius' value='update' &gt;
  
  &lt;/form&gt;
  
  
  &lt;/label&gt;
  </code></pre>
  
  <p>so that should display whats currently in the database then when a user changes it they click update and it should up date in the database </p>
  
  <p>here is the update.php</p>
  
  <pre><code>// Create connection
  $conn = new mysqli($servername, $username, $password, $dbname);
  // Check connection
  if ($conn-&gt;connect_error) {
  die("Connection failed: " . $conn-&gt;connect_error);
  }
  $title =$_POST['title'];
  $var_value = $_GET['id'];
  
  $result = $conn-&gt;query($sql);
  
  $sql = "UPDATE aparthousesalerent SET title='$title' WHERE id  = '$var_value' ";
  
  echo $var_value;
  echo $title;
  
  if ($conn-&gt;query($sql) === TRUE) {
  
  } else {
  echo "Error: " . $sql . "&lt;br&gt;" . $conn-&gt;error;
  }
  
  $conn-&gt;close();
  </code></pre>
  
  <p>i added in the extra line of echo $var_value and echo $title; to check if that worked and it did but it still doesn't pass it through to the database </p>
  
  <p>thanks for looking  </p>