title: Passing a value retrieved from a database to another page using php and mysql
body: <p>I am trying to pass a value that I have received from my database to another php page to use within another SQL statement.
  I have tried using sessions and also passing using the $_POST method on the other page but have had no luck.</p>
  
  <p>Here is a snippet of my code looping through to display all records:</p>
  
  <pre><code>while($row = mysqli_fetch_array($sql)){
  echo '&lt;td&gt;
            &lt;img src='.'"'.$row['image'].'"'.'&gt;&lt;br/&gt;
            &lt;form method="post" action="edit-record.php"&gt;
            &lt;input type="text" name="imgID" value='.'"'.$row['id'].'"'.'&gt;
            &lt;input type="submit" value="Edit" id="edit_btn" class="admin_btn"&gt;&lt;/form&gt;
        &lt;/td&gt;';
  }
  </code></pre>
  
  <p>The value that I need is the ID for each specific image - <code>$row['id']</code>.</p>
  
  <p>When the user clicks the EDIT button, they should be redirected to another page which displays only the specific record. This is why I need the ID received passed to the next page to insert into a query statement.</p>
  
  <p>I hope this made sense and any help will be greatly appreciated.</p>
  
  <p><strong>UPDATE:</strong> Thanks for all of your help. I solved the problem by playing around with a few of your suggestions to pass the id via GET in the action of the form. </p>
  
  <p><code>&lt;form method="post" action="edit-record.php?id='. $row['id'].'"&gt;</code></p>
  
  <p>No idea why that hadn't occurred to me! Thanks again.</p>