Needs to be executed after the tm_conversion script since it's using tm_id

//Run more than once: parse max one league per run
**/
require 'helper.php';
$leagueURL = array();
//$leagueURL[]="http://www.transfermarkt.it/serie-a/startseite/wettbewerb/IT1/plus/?saison_id=";
//$leagueURL[]="http://www.transfermarkt.it/premier-league/startseite/wettbewerb/GB1/plus/?saison_id=";
$leagueURL[] = "http://www.transfermarkt.it/primera-division/startseite/wettbewerb/ES1/plus/?saison_id=";
//$leagueURL[]="http://www.transfermarkt.it/1-bundesliga/startseite/wettbewerb/L1/plus/?saison_id=";
echo '<div class="row"><div class="col-md-6">';
$row = new DataRow();
foreach ($leagueURL as $url) {
    $league_id = setTMLeagueId($url);
    for ($year = 2010; $year <= 2015; $year++) {
        $html = file_get_html_tm($url . $year);
        echo "<b>Parsing transfermarkt stats for league={$league_id} and year={$year}</b><br>";
        //result
        $dataArray = [];
        $div = $html->find('div[id=yw1]')[0];
        foreach ($div->find('table[class=items]') as $table) {
            foreach (array_slice($table->find('tr'), 2) as $tr) {
                //echo $tr."<br>";
                $tm_id = $tr->find('a[class=vereinprofil_tooltip]', 1)->id;
                $row->getTMTeamId($conn, $tm_id);
                $row->league_id = $league_id;
                $row->year = $year;
                //check if table row has been inserted already
                if ($row->TMrowInserted($conn)) {
                    //one for each input
                    $Players_Num = $tr->find('td', 3)->plaintext;
require 'helper.php';
//error_reporting(0);
$leagueURL = array();
//$leagueURL[]="http://www.transfermarkt.it/serie-a/tabelle/wettbewerb/IT1?saison_id=";
//$leagueURL[]="http://www.transfermarkt.it/premier-league/tabelle/wettbewerb/GB1/saison_id/";
$leagueURL[] = "http://www.transfermarkt.it/primera-division/tabelle/wettbewerb/ES1/saison_id/";
$leagueURL[] = "http://www.transfermarkt.it/1-bundesliga/tabelle/wettbewerb/L1/saison_id/";
$inserted_id = array();
echo '<div class="row"><div class="col-md-6">';
$rank_id = findRankID($conn);
if ($rank_id > 0) {
    foreach ($leagueURL as $url) {
        $league_id = setTMLeagueId($url);
        for ($i = 2010; $i <= 2015; $i++) {
            $html = file_get_html_tm($url . $i);
            echo "<br><h1>{$league_id}----{$i}</h1></br>";
            //result
            foreach ($html->find('div[class=responsive-table]') as $div) {
                foreach ($div->find('table') as $table) {
                    //echo $table;
                    foreach ($table->find('tr') as $tr) {
                        echo $position = $tr->find('td', 0)->plaintext * 1;
                        echo "         ";
                        echo $tm_id = $tr->find('a[class=vereinprofil_tooltip]', 0)->id;
                        echo "         ";
                        if ($position > 0 && !in_array($tm_id, $inserted_id)) {
                            echo "{$position}---{$tm_id}<img src='img/{$tm_id}.png'  height='25' width='25'><br>";
                            $sql = "UPDATE `team` SET `tm_id`={$tm_id}, logo='" . $tm_id . ".png' WHERE id in (SELECT `team_id` FROM `seasonal_data` WHERE `input_id` = {$rank_id} and `year` = {$i} and value= {$position} and `league_id` = {$league_id})";
                            //echo "<br>";
                            if ($conn->query($sql)) {