title: What am I doing wrong? Edit table data in form
body: <p>I have a table with a edit link and a delete button on each row. Delete button is working fine but the edit link I don´t know what I´m doing wrong with!</p>
  
  <p>Clicking the edit link for a specific row it leads to edit page with the form BUT the data is not filled out. There is no error message... I can see up in the URL field that it´s the correct id for the chosen movie. </p>
  
  <p>What am I missing? Do I need to write any queries etc on the edit page as well? I did try and make it a require page so when clicking on the edit button the edit form pops up on the index page. But I couldn't manage to do that.</p>
  
  <p>I know I'm using mysql functions which are outdated, and I have yet to add SQL protection.</p>
  
  <p><strong>The database is called moviedata and has 2 tables.</strong> </p>
  
  <ul>
  <li>Table 1 is called: movies   
  
  <ul>
  <li>Fields/columns (5): <strong>id</strong> (primary key, AI),   ****title**  , <strong>release_year</strong>,**   ****genre_id**, **director****</li>
  </ul></li>
  <li>Table 2 is called: categories
  
  <ul>
  <li>Fields/columns (2): <strong>genre_id</strong> (primary key, AI), <strong>genre</strong></li>
  </ul></li>
  </ul>
  
  <p>There is a relation (Foreign key) between genre_id (primary key,    table 2) and genre_id (table 1).</p>
  
  <p><strong>index.php code</strong> </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  
  &lt;html&gt;
  
  &lt;head&gt;
  
  &lt;title&gt;My movie library&lt;/title&gt;
  &lt;meta charset="utf-8" /&gt;
  &lt;link rel="stylesheet" href="mall.css" /&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;?php 
  
      require 'connect.inc.php';
  
      if (isset($_POST['delete']) &amp;&amp; isset($_POST['id'])) {
          $id = $_POST['id'];
          $query = "DELETE FROM movies WHERE id=".$id." LIMIT 1";
  
          if (!mysql_query($query, $sql))
              echo "DELETE failed: $query&lt;br&gt;".
              mysql_error() . "&lt;br&gt;&lt;br&gt;";
      }
  
      $query = "SELECT * FROM movies m INNER JOIN categories c ON m.genre_id = c.genre_id";
      $result = mysql_query($query);
  
      if (!$result) die ("Database access failed:" .mysql_error()) ;
      $rows = mysql_num_rows($result);
  
      echo '&lt;table&gt;&lt;tr&gt;&lt;th&gt;Title&lt;/th&gt;&lt;th&gt;Release year&lt;/th&gt;&lt;th&gt;Genre&lt;/th&gt;&lt;th&gt;Director&lt;/th&gt;&lt;th&gt;Update&lt;/th&gt;&lt;th&gt;Delete&lt;/th&gt;&lt;/tr&gt;';
  
      while ($row = mysql_fetch_assoc($result)) {
      echo '&lt;tr&gt;&lt;td&gt;' .$row["title"] . '&lt;/td&gt;' ;
      echo '&lt;td&gt;' .$row["release_year"] . '&lt;/td&gt;' ;
      echo '&lt;td&gt;' .$row["genre_id"] . '&lt;/td&gt;' ;
      echo '&lt;td&gt;' .$row["director"] . '&lt;/td&gt;' ;
      echo '&lt;td&gt;'."&lt;a href='edit_movie.php?edit=" . $row["id"] . "'&gt;Edit&lt;/a&gt;".'&lt;/td&gt;';
      echo '&lt;td&gt;&lt;form action="index.php" method="POST"&gt;
                  &lt;input type="hidden" name="delete" value="yes" /&gt;
                  &lt;input type="hidden" name="id" value="'. $row["id"] .'" /&gt; 
                  &lt;input type="submit" value="Delete" /&gt;&lt;/form&gt;
                  &lt;/td&gt;&lt;/tr&gt;' ;
      }
      echo '&lt;/table&gt;'; 
  
  ?&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>And here is the code on edit_movie.php page. The edit page with the form:</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  
  &lt;html&gt;
  
  &lt;head&gt;
  
  &lt;title&gt;My movie library&lt;/title&gt;
  &lt;meta charset="utf-8" /&gt;
  &lt;link rel="stylesheet" href="mall.css" /&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;?php
  
  require 'connect.inc.php';
  
  
  //close MySQL
  mysql_close($sql);
  
  ?&gt;
  
  &lt;p&gt;Edit movie&lt;/p&gt;
  &lt;div id="form_column"&gt;
  &lt;form action="edit_movie.php" method="post"&gt;
  &lt;input type="hidden" name="id" value="&lt;?php if (isset($row["id"])) ?&gt;" /&gt; &lt;br&gt;
  Title:&lt;br&gt; &lt;input type="text" name="title" value="&lt;?php if (isset($row["title"])) { echo $row["title"];} ?&gt;" /&gt; &lt;br&gt;
  Release Year:&lt;br&gt; &lt;input type="text" name="release_year" value="&lt;?php if (isset($row["release_year"])) { echo $row["release_year"];} ?&gt;" /&gt; &lt;br&gt;
  Director:&lt;br&gt; &lt;input type="text" name="director" value="&lt;?php if (isset($row["director"])) { echo $row["director"];} ?&gt;" /&gt; &lt;br&gt;&lt;br&gt;
  Select genre:
  &lt;br&gt;
  &lt;br&gt; &lt;input type="radio" name="genre_id" value="1" checked /&gt;Action&lt;br&gt;
  &lt;br&gt; &lt;input type="radio" name="genre_id" value="2" /&gt;Comedy&lt;br&gt;
  &lt;br&gt; &lt;input type="radio" name="genre_id" value="3" /&gt;Drama&lt;br&gt;
  &lt;br&gt; &lt;input type="radio" name="genre_id" value="4" /&gt;Horror&lt;br&gt;
  &lt;br&gt; &lt;input type="radio" name="genre_id" value="5" /&gt;Romance&lt;br&gt;
  &lt;br&gt; &lt;input type="radio" name="genre_id" value="6" /&gt;Thriller&lt;br&gt;&lt;br&gt;
  &lt;input type="submit" /&gt;
  &lt;/form&gt;
  &lt;/div&gt;
  
  
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>The database connection is in a separate connect.inc.php file which is required at the top of these files. The code in the connect.inc.php file you can see below:</strong></p>
  
  <pre><code>&lt;?php
  
  
  //connect to MySQL
  $servername = "localhost";
  $username = "root";
  $password = "";
  $sql = mysql_connect($servername,$username,$password);
  mysql_connect($servername,$username,$password);
  //select database
  mysql_select_db("moviedata");
  
  ?&gt;
  </code></pre>