通过选定位置更新MySQL

I am trying to update a table based on the input provided by a user. There are ten fields which a user can choose to input information into. The table I am trying to input too has a following structure.

leagueTrackID | leagueID | trackID

   1                1          1

   2               1          2

   3               1          12

   ...

   15              1          4    

I need the code to update the fields where a new track has been added via looping though each inputted track and place it in a new field which has the matching criteria. The criteria which it needs to be match too is the leagueID. How can this be achieved without overwriting the same column row?

The code below is what I have so far but I have an error with trying to assign the php track variables to either a php array or php list.

$data = mysql_query("SELECT COUNT(leagueID) AS totalTracks , min(leagueTrackID) AS minLeagueID , max(leagueTrackID) AS maxLeagueID , leagueID , trackID
              FROM leagueTracks
              WHERE leagueID = '$vaildLeagueID'");

$info = mysql_fetch_array( $data );

// get posted track id and assign them to the php track varaibles
if ( $_POST['track1'] == '' )  {     $track1 = $info['track1']; } else {    $track1 = $_POST['track1'];  }
if ( $_POST['track2'] == '' )  {     $track2 = $info['track2']; } else {    $track2 = $_POST['track2'];  }
if ( $_POST['track3'] == '' )  {     $track3 = $info['track3']; } else {    $track3 = $_POST['track3'];  }
if ( $_POST['track4'] == '' )  {     $track4 = $info['track4']; } else {    $track4 = $_POST['track4'];  }
if ( $_POST['track5'] == '' )  {     $track5 = $info['track5']; } else {    $track5 = $_POST['track5'];  }
if ( $_POST['track6'] == '' )  {     $track6 = $info['track6']; } else {    $track6 = $_POST['track6'];  }
if ( $_POST['track7'] == '' )  {     $track7 = $info['track7']; } else {    $track7 = $_POST['track7'];  }
if ( $_POST['track8'] == '' )  {     $track8 = $info['track8']; } else {    $track8 = $_POST['track8'];  }
if ( $_POST['track9'] == '' )  {     $track9 = $info['track9']; } else {    $track9 = $_POST['track9'];  }
if ( $_POST['track10'] == '' ) {     $track10 = $info['track10']; } else {  $track10 = $_POST['track10'];  }


// Assign tracks selected to an array
$tracksArray = array($track1 , '$track2' , '$track3', '$track4', '$track5' , '$track6' ,'$track7', '$track8' , '$track9' , '$tack10');

// Counter
$trackNumber = '1';

// Get the lowest leagueTrackID based on the leagueID being updated
$min = $info['minleagueID']; 

// Get the highest leagueTrackID based on the leagueID being updated
$max = $info['maxLeagueID'];

      while($min != $max) {

    $updateLeagueTracks = mysql_query ("UPDATE userLeague SET trackID = $trackArray['$tracknumber'] WHERE leagueID = '$vaildLeagueID'");

    $addTracks = mysql_query($updateLeagueTracks);

    $trackNumber++;
    $min++;

} // closes the for loop