title: How to pull data from MySQL database with PHP based on DB entry ID
body: <p>I am complete newbie to PHP/SQL and all this stuff, also not really skilled with any kind of programming. My problem is that I am currently trying to pull out data from MySQL table on to website, but after finishing the code it pulls out all of the data from my table.
  I would love to somehow get to pull out only data from specific table row, based on it's primary key. My current code looks like this. </p>
  
  <pre><code>    &lt;?php
  $servername = "localhost";
  $username = "root";
  $password = "";
  $dbname = "rainbow";
  
  $link = mysqli_connect($servername, $username, $password, $dbname);
  
  if($link === false){
    die("ERROR: COuld not connect." . mysqli_connect_error());
  }
  
  $sql = "
  SELECT name
       , nick
       , surname
       , team
       , country
       , birthdate
       , mouse
       , dpi
       , keyboard
       , headset 
    FROM players
  ";
  if($result = mysqli_query($link, $sql)){
    if(mysqli_num_rows($result) &gt; 0){
      echo "&lt;table&gt;";
        echo "&lt;tr&gt;";
          echo "&lt;th&gt;name&lt;/th&gt;";
          echo "&lt;th&gt;nick&lt;/th&gt;";
          echo "&lt;th&gt;surname&lt;/th&gt;";
          echo "&lt;th&gt;team&lt;/th&gt;";
          echo "&lt;th&gt;country&lt;/th&gt;";
          echo "&lt;th&gt;birthdate&lt;/th&gt;";
          echo "&lt;th&gt;mouse&lt;/th&gt;";
          echo "&lt;th&gt;dpi&lt;/th&gt;";
          echo "&lt;th&gt;keyboard&lt;/th&gt;";
          echo "&lt;th&gt;headset&lt;/th&gt;";
        echo "&lt;/tr&gt;";
      while ($row = mysqli_fetch_array($result)){
          echo "&lt;tr&gt;";
            echo "&lt;td&gt;" . $row['name'] . "&lt;/td&gt;";
            echo "&lt;td&gt;" . $row['nick'] . "&lt;/td&gt;";
            echo "&lt;td&gt;" . $row['surname'] . "&lt;/td&gt;";
            echo "&lt;td&gt;" . $row['team'] . "&lt;/td&gt;";
            echo "&lt;td&gt;" . $row['country'] . "&lt;/td&gt;";
            echo "&lt;td&gt;" . $row['birthdate'] . "&lt;/td&gt;";
            echo "&lt;td&gt;" . $row['mouse'] . "&lt;/td&gt;";
            echo "&lt;td&gt;" . $row['dpi'] . "&lt;/td&gt;";
            echo "&lt;td&gt;" . $row['keyboard'] . "&lt;/td&gt;";
            echo "&lt;td&gt;" . $row['headset'] . "&lt;/td&gt;";
          echo "&lt;/tr&gt;";
      }
      echo "&lt;/table";
      mysqli_free_result($result);
      }
      else {
        echo "Ziadny vysledok a nic nefunguje";
    }
  }
  
  mysqli_close($link);
  ?&gt;
  </code></pre>
  
  <p>To be honest, I am not even sure if this is the right way to do it, but it works and it pulls the data into a HTML table which is not necessary for me, I just wanted to try it. Thanks for answers!</p>