mysql - PHP+SQL Shuffle results from one table and save to onother one -


i have write script in php shuffle players ids, pair them , save 1 table.

from first table player ids using simple sql query:

select id table1 

it gives me e.g. result ids: 1, 2, 3, 4, 5

now issue begins.

i have shuffle sql result e.g. result 2, 5, 4, 1, 3

then need pair players ids (after shuffle) that:

first row - first player second player second row - second player third player third row - third player fourth player fourth row - fourth player fifth player fifth row - fifth player first player 

in sql table2 if should below:

2-5 5-4 4-1 1-3 3-2 

what looking is:
1. way shuffle sql result players id
2. way pair results shuffled result
3. way save table2

what should use shffle(). takes array , shuffles it. can use each array in order.

example

array1 [1] [2] [3] [4]  array2 [1] [2] [3] [4]   $array3 = shuffle($array2);  array3  [2] [1] [4] [3] 

then loop through them

for($i=0;$i<4;i++){     echo $array1[$i] .' vs '. $array3[$i]; } 

Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -