I have the following problem:
"Imagine we have the records of a lottery, but we need to sort the values. I already tried the documentation code for php
- asort
, but it does not work!
I'm using the 7.2.4
version of php
(hope you do not have a bug!)
Iwanttosortthenumbersthatareinn1
,n2
,n3
,n4
,n5
andn6
.
Ex:id=2032
,itshouldhaven1=6
,n2=14
,n3=19
,n4=20
,n5=39
andn6=53
.
Code:
$result=mysqli_query($db,"SELECT * FROM table32");
while ($dados = mysqli_fetch_array($result, MYSQLI_BOTH)) {
$valores = array(
"n1" => $dados['n1'], "n2" => $dados['n2'],
"n3" => $dados['n3'], "n4" => $dados['n4'],
"n5" => $dados['n5'], "n6" => $dados['n6']
);
asort($valores);
foreach ($valores as $n => $val) {
echo "$n = $val"; //Não chega aqui!
}
}