Jump to content

diablo3

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

diablo3's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks DavidAM!! That worked, and I see the logic... And thanks for the other replies too...
  2. Hi. I made a poor job of explaining my last post, which caused some frustration, so this time I will try to explain a bit better - and hopefully get a better result... Here goes... I have 2 arrays, called $old_teams1 and $old_teams2.... $old_teams1 represents side 1 of the fixtures, and $old_teams2 represents side 2 of the fixtures... Both these arrays may vary in size depending on how many fixtures/teams there are.... This table represents the 2 arrays: Fixture$old_team1$old_team2 134 241 332 442 513 621 With less or more teams, there would be more or less fixtures.. In the above table, there are 4 teams... So the 2 end colomns, represent the arrays... The numbers (with 4 teams) as above, vary from obviously 1-4... and with more teams, a bigger range. However these numbers are not the actual team ID numbers, as defined in the MySQL database. If the team ID numbers defined in the database, are stored in the array, called $teams_arr for example... The actual numbers of the teams, in the database may vary depending.. but for now... lets say $teams_arr is the following: $teams_arr = Array ( [0] => 3 [1] => 5 [2] => 6 [3] => 8 ) How do I go about substituting all instances, of 1's for 3's, 2's for 5's, 3's for 6's and 4's for 8's, .... I need to convert the existing values as stored in $old_teams1 and $old_teams2, into the new $teams_arr values... I hope you understand what I'm getting at...
  3. Ok, now I'm trying to apply this, from the random array that I have generated... so... for example... $non_rand_arr is an array of... [0] => 1 [1] => 2 [2] => 3 [3] => 4 etc... (increasing with count()) and... $rand_arr could be [0] => 2 [1] => 4 [2] => 1 [3] => 3 The arrays of numbers to be changed are $old_teams1 and $old_teams2.... which can be any one of the numbers in the range of the $non_rand_arr... in this case 1-4, although it could be 1-9++... so, would I use a for loop to convert each of the $old_teams1 and $old_teams2 to its new values, with the switch()... as demonstrated?
  4. Ok, well I have already used shuffle... to reorder the numbers... I would like to convert all instances of 1 to 3, 2 to 4, 3 to 1, 4 to 2, in both arrays...
  5. Hi, I have 2 arrays, named $old_teams1 and $old_teams2. The arrays have from 6 values upwards. If $old_teams1 looks like this: Array ( [0] => 3 [1] => 4 [2] => 3 [3] => 4 [4] => 1 [5] => 2 ) and $old_teams2 is the has the same mixture of values from 1-4..... .. How do I create a loop that will change all values of $old_teams1 and $old_teams2 to new values such as, 1->3, 2->4, 3->1, 4->2.... (The new values have been randomly generated).
  6. I have an SQL table such as this: Pairing1Pairing2Week 611 521 431 132 542 362 and another with teams such as: teamidteamname 1Teamname 1 2Teamname 2 3Teamname 3 The numbers in the pairing are numbers of teams, which is in another SQL table. What would be the most efficient way... of displaying the information in the form of pairngs such as Week 1: Team 6 vs Team 1 Team 5 vs Team 2 etc .... What is the best way for me to sort my results?
  7. It's really frustrating, but I still can't get it to work!!! I tried Pandemikk's code, that failed too... It should be very simple... I want to update a table, with these random numbers: Array ( [0] => 4 [1] => 2 [2] => 5 [3] =>1 [4] => 3 ) I'm pretty confused!!! lol
  8. the output for values 1-5 in the team_id colomn.. with the random numbers: 2, 3, 1, 5, 4 team_id: 3 2 3 4 5
  9. I have retrieved 5 values from a database table... The table is such as-> tmeta_idteam_id 11 22 33 44 55 Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 ) .. and this array I have named $nonrandom_teamno. using shuffle() I have rearranged the array, the new array being $random_teamno, which is such as the following-> Array ( [0] => 3 [1] => 4 [2] => 5 [3] => 2 [4] => 1 ) I am having real problems reinserting this into the SQL tables... I have been trying the foreach loop below... for($i = 1; $i < (count($nonrandom_teamno)+1); $i++) { $db->query("UPDATE ancl_teammeta SET team_id ='$random_teamno[$i]' WHERE tmeta_id='$nonrandom_teamno[$i]'"); } It puts numbers back in the database, but not random ones. Please help me with the correct query I need!! Thank you..
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.