title: PHP MYSQL $_GET['ID'] from table on dynamically generated page
body: <p>I have a few products stored in a table with auto-incremented ID entitled "product_id".</p>
  
  <p>I have managed to create a page that displays a list of the products names as selected from the db and dynamically created links for each one. Let's say I have product apple. When I click on apple it takes me to view_product_details.php?id=9</p>
  
  <p>But when I click apple, the view_product_details.php page tells me
  "Notice: Undefined index: product_id in C:\xampp\htdocs\working\product-website-exercise\view_product_details.php on line 16"</p>
  
  <pre><code>&lt;?php 
  
  //$result = mysql_query("SELECT * FROM temaproduct.products WHERE ID = '".mysql_real_escape_string($_GET['product_id'])."'");
  
  
          $id = $_GET['product_id']; //This is line 16
  
          $result = mysqli_query($conn,"SELECT * FROM products WHERE ID = $id");
  
          echo $result['product_description'];
  
  echo "&lt;br&gt;";
  var_dump($result);
  
  ?&gt;
  </code></pre>
  
  <p>I have tried with different queries but can't figure it out, please help me establish the connection properly so I can read the other fields from the table on the view_product_details page, based on product_id.</p>
  
  <p>EDIT: Thank you guys, with your help, here is the code that works now, if everybody needs this snippet:</p>
  
  <pre><code>&lt;?php
  $id = intval($_GET['id']); 
  $sql = mysqli_query($conn,"SELECT * FROM products WHERE product_id = ".$id);
  if(mysqli_num_rows($sql)){
      $product_data = mysqli_fetch_array($sql);
      echo "&lt;h2&gt;&lt;center&gt;".$product_data['title']."&lt;/h2&gt;&lt;/center&gt;";
  }
  ?&gt;
  </code></pre>