Hello i have tables like this :
Employee
EmployeeID EmployeeName
1234 Suho
1235 Kai
1236 Baekhyun
1237 Lay
1238 D.O
1239 Chen
1240 Chanyeol
1241 Xiumin
1242 Sehun
i used this source code to make random data :
<?php
mysql_connect("localhost", "root", "1234") or die(mysql_error());
mysql_select_db("Employee") or die(mysql_error());
$employees = mysql_query("select p.*
from (select (@c := CHAR(ASCII(@c) + 1)) as c, EmployeeName
from Employee cross join
(select @c := 'A') params
order by EmployeeId
) p order by rand();")
or die(mysql_error());
$letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$position = 0;
$position2 = 0;
$toomany = '';
while($row = mysql_fetch_array( $employees )) {
echo "<DIV>" . $toomany.substr($letters, $position, 1) . " = " . $row['EmployeeName'] . " </div>";
$position ++;
if($position > 25) {
$position = 0;
$position2 ++;
if($position2 > 25) { echo "We need to rethink this idea."; break; }
$toomany = substr($letters, $position2, 1);
}
}
?>
After random the data, the result is like this :
A = Sehun
B = Suho
C = Kai
D = D.O
E = Chen
F = Chanyeol
G = Baekhyun
F = Lay
H = Xiumin
or like this :
A = Kai
B = Suho
C = Sehun
D = D.O
E = Chen
F = Xiumin
G = Lay
F = Chanyeol
H = Baekhyun
The problem is i want to random that data like this (From the database before, EmployeeID changed by alphabet sequentially):
A = Suho
B = Kai
C = Baekhyun
D = Lay
E = D.O
F = Chen
G = Chanyeol
H = Xiumin
I = Sehun
into this one, the data have with the same value but with a different sequence (Only their potition change, not only their names were randomized) :
G = Chanyeol
C = Baekhyun
B = Kai
D = Lay
I = Sehun
E = D.O
F = Chen
A = Suho
H = Xiumin
or like this :
I = Sehun
E = D.O
C = Baekhyun
G = Chanyeol
B = Kai
H = Xiumin
D = Lay
F = Chen
A = Suho
May you know where is the problem? Thank you for your help.