Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In <code>edit_movie.php</code> it doesn't look like you're actually getting the movie passed view the form. You need something like this in your <code>movie.inc.php</code>:</p> <pre><code>function get_movie_to_edit($id) { $query = "SELECT * FROM movies m INNER JOIN categories c ON m.genre_id = c.genre_id WHERE id = $id"; $result = mysql_query($query); if ( ! $result ){ return false; } else { while ($row = mysql_fetch_assoc($result)){ $return = array('director' =&gt; $row['director'], 'genre' =&gt; $row['genre'], 'release_year' =&gt; $row['release_year'], 'title' =&gt; $row['title'], 'id' =&gt; $row['id']); } return $return; } } </code></pre> <p>And then in edit_movie.php you need to call this function. Something like...</p> <pre><code>if(isset($_GET['edit'])) { $movie = get_movie_to_edit($_GET['edit']); } </code></pre> <p>Of course, as you mentioned, you need to clean up a lot of the code to prevent against injection and check for a scenario where, say, you get to <code>edit_movie.php</code> and the ID ro edit doesn't exist, but this is the basic gist.</p> <p>You would also then edit the values in the form in <code>edit_movie.php</code> to reflect the new array like:</p> <pre><code>&lt;form action="edit_movie.php" method="post"&gt; &lt;input type="hidden" name="id" value="&lt;?php echo $movie['id']; ?&gt;" /&gt; &lt;br&gt; Title:&lt;br&gt; &lt;input type="text" name="title" value="&lt;?php echo $movie['title']; ?&gt;" /&gt; &lt;br&gt; .... the rest of your form inputs &lt;/form&gt; </code></pre> <p><strong>Updated</strong> For the genre radio buttons...</p> <pre><code>&lt;input type="radio" name="genre_id" value="1"&lt;?php if($movie['genre'] == 1) { echo ' checked'; } ?&gt; /&gt;Action&lt;br&gt; &lt;input type="radio" name="genre_id" value="2"&lt;?php if($movie['genre'] == 2) { echo ' checked'; } ?&gt; /&gt;Comedy&lt;br&gt; .... and so on </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload