title: How can i get data from a phpmyadmin table to display in the order it is entered into the database
body: <p>I am creating a Fantasy Football website and I'm having problems getting the data from my database to display in the correct order.</p>
  
  <p>I need the data to display in this order GK1, GK2, Def1, Def2, Def3, Def4, Def5, Mid1, Mid2, Mid3, Mid4, Mid5, For1, For2, For3.</p>
  
  <p><a href="https://i.stack.imgur.com/pEfad.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pEfad.png" alt="Database Table"></a>
  <a href="https://i.stack.imgur.com/j7FGN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/j7FGN.png" alt="enter image description here"></a></p>
  
  <p>As you can see the first Midfielder shown should be Ozil as he is 181 and at Mid1. However Midfielder1 shows as 176 is below 181.</p>
  
  <p>The table contains the IDs of the players in the PremPlayers table i then do a join to display the data</p>
  
  <p>My Select statement: </p>
  
  <pre><code>SELECT PremPlayers.LastName , PremPlayers.Img FROM `PremPlayers`
  INNER JOIN FantasyLogin
  ON PremPlayers.ID=FantasyLogin.GK1 OR PremPlayers.ID=FantasyLogin.GK2 OR PremPlayers.ID=FantasyLogin.Def1 OR PremPlayers.ID=FantasyLogin.Def2 OR PremPlayers.ID=FantasyLogin.Def3 OR PremPlayers.ID=FantasyLogin.Def4 OR PremPlayers.ID=FantasyLogin.Def5 OR PremPlayers.ID=FantasyLogin.Mid1 OR PremPlayers.ID=FantasyLogin.Mid2 OR PremPlayers.ID=FantasyLogin.Mid3 OR PremPlayers.ID=FantasyLogin.Mid4 OR PremPlayers.ID=FantasyLogin.Mid5 OR PremPlayers.ID=FantasyLogin.For1 OR PremPlayers.ID=FantasyLogin.For2 OR PremPlayers.ID=FantasyLogin.For3
  Where FantasyLogin.ID = '$UserID' 
  ORDER BY PremPlayers.PositionID
  </code></pre>
  
  <p>The issue is that it is displaying the players in order of ID and there fore when a user goes to change the player it doesn't necessarily select the correct one.</p>
  
  <p>php code to display players:</p>
  
  <pre><code>function displayData($result){ 
          while ($row = $result-&gt;fetch_assoc()){ 
              $playerno = $playerno +1;
              print "&lt;div class='col-md-2'&gt;";
              print "    &lt;h3&gt;" . $row["LastName"] . "&lt;/h3&gt;"; 
              print "    &lt;img class='img-responsive' src='assets/img/". $row["Img"] .".jpg' alt='No Image Found'&gt;
    &lt;p&gt;&lt;br&gt;&lt;a class='btn btn-success' href='removeplayer" . $playerno . ".php' role='button'&gt;Pick Player " . $playerno . "&lt;/a&gt;&lt;br&gt;&lt;/p&gt;
     &lt;/div&gt;";
          } 
     print "&lt;/div&gt;";
  
    }
  </code></pre>