title: Connecting html form to php page according to primary key
body: <p>Ok so essentially what I'm trying to do is add a q&amp;a component to my website (first website, so my current php knowledge is minimal). I have the html page where the user's input is recorded, and added to the database, but then I'm having trouble pulling that specific info from the database. </p>
  
  <p>My current php page is pulling info where <code>the questiondetail</code> = <code>the question detail</code> (<code>detail='$detail'</code>) in the database, but that could potentially present a problem if two users enter the same information as their question details (unlikely, but still possible, especially if the same person accidentally submits the question twice). What I want to do is have the page load according to the database's question_id (primary key) which is the only thing that will always be unique.</p>
  
  <p>HTML CODE:</p>
  
  <pre><code>&lt;form id="question_outline" action="process.php" method="get"&gt;
  &lt;p&gt;&lt;textarea name="title" id="title_layout" type="text"  placeholder="Question Title" &gt;&lt;/textarea&gt; &lt;/p&gt;
  &lt;textarea name="detail"  id= "detail_layout" type="text" placeholder="Question Details"  &gt;&lt;/textarea&gt;
  &lt;div id="break"&gt; &lt;/div&gt;
  &lt;input id="submit_form" name="submit_question" value="Submit Question" type="submit" /&gt; 
  &lt;/form&gt;
  </code></pre>
  
  <p>PROCESS.PHP CODE:</p>
  
  <pre><code>$name2 = $_GET['name2'];
  $title = $_GET['title'];
  $detail = $_GET['detail'];
  
  $query= "INSERT INTO questions (title, detail) VALUES ('$title', '$detail')";
  
  $result = mysql_query("SELECT * FROM questions where detail='$detail' ") 
  or die(mysql_error());  
  </code></pre>
  
  <p>The info is being stored correctly in the database, and is being pulled out successfully when detail=$detail, but what I'm looking to do is have it pulled out according to the question_id because that is the only value that will always be unique. Any response will be greatly appreciated!</p>
  
  <p><em><strong>Updated Version</em></strong></p>
  
  <p>QUESTION_EXAMPLE.PHP CODE</p>
  
  <pre><code>&lt;?php
  $server_name = "my_servername";
  $db_user_name ="my_username";
  $db_password = "my_password";
  $database = "my_database";
  $submit = $_GET['submit'];
  $title = $_GET['title'];
  $detail = $_GET['detail'];
  $conn = mysql_connect($server_name, $db_user_name, $db_password);
  
  mysql_select_db($database) or die( "Unable to select database");
  
  $result = mysql_query("SELECT title, detail FROM questions WHERE id =" .
  mysql_real_escape_string($_GET["id"]), $conn);
  
  $row = mysql_fetch_assoc($result);
  
  mysql_close($conn);
  
  ?&gt;
  
  &lt;h1&gt;&lt;?php echo htmlspecialchars($row["title"]);?&gt;&lt;/h1&gt;
  &lt;p&gt;&lt;?php echo htmlspecialchars($row["detail"]);?&gt;&lt;/p&gt;
  </code></pre>