 <p>Why don't you query the database once to catch all information? Take a look at this:</p> <pre><code>connect(); $sql = 'SELECT gameid, mizbanid, mihmanid, score1, score2, gamedavar, gamestadium, now FROM games WHERE gameweek = ' . $site_week . ' ORDER BY now ASC LIMIT 9'; $query = mysql_query($sql); if(mysql_num_rows($query)) { while($Result = mysql_fetch_object($query)) { //loop trough results print_r($Result); //prints the results. echo $Result-&gt;gameid; //this is how you echo the data } } </code></pre> <p>Be aware that the mysql_query function is deprecated and needs to be replaced by mysqli :) .</p>