So this is driving me nuts. I need to pull my table rows from mySQL and then sort them but then i need to output them back as single arrays. Mostly because the code after this is written to accept that.
Here is my code. please let me know if you have any suggestions.
<?php
include 'connect.php';
$query = mysql_query("SELECT * FROM users");
while ($data = mysql_fetch_assoc($query))
{
$newarray[]=$data;
$dbusername = $data['username'];
$dbpassword = $data['password'];
$logid = $data['id'];
print_r ($data);
echo "<br/>";
}
foreach ($newarray as $key => $row) {
$volume[$key] = $row['password'];
}
array_multisort($volume, SORT_ASC, $newarray);
print_r($newarray);
?>
The result of this is:
Array (
[0] => Array ( [id] => 4 [rating] => 18 [password] => 1981 [username] => 212060064)
[1] => Array ( [id] => 2 [rating] => 6 [password] => 1983 [username] => 212060062)
[2] => Array ( [id] => 3 [rating] => 5 [password] => 1984 [username] => 212060063)
[3] => Array ( [id] => 1 [rating] => 3 [password] => 1988 [username] => 212060061)
)
However I need to output them like this:
Array ( [id] => 4 [rating] => 18 [password] => 1981 [username] => 212060064)
Array ( [id] => 2 [rating] => 6 [password] => 1983 [username] => 212060062)
Array ( [id] => 3 [rating] => 5 [password] => 1984 [username] => 212060063)
Array ( [id] => 1 [rating] => 3 [password] => 1988 [username] => 212060061)