When I use the following code:
$result = queryMysql("SELECT * FROM games ORDER BY game ASC");
$num = $result->num_rows;
for ($j = 0 ; $j < $num ; ++$j)
{
$row = $result->fetch_array(MYSQLI_ASSOC);
echo "<input type='checkbox' name='game' value='$row['id']'>$row['game']<br>";
}
the result is not shown alphabetically. it has Destiny first, and Battlefield last. Destiny has ID 1, and Battlefield has ID 11.
Why isn´t it being sorted? If I use the command in PhpMyAdmin I get the list back sorted.
(Sorry if this is too simple, but I didn´t find any solutions here. All refered to use ORDER BY, but that´s not working).
New code changed to:
$result = queryMysql("SELECT * FROM games ORDER BY game ASC");
while ($row = $result->fetch_array(MYSQLI_ASSOC))
{
echo "<input type='checkbox' name='game' value='$row['id']'>$row['game']<br>";
}
Still not working. Could this be a server error?
Not sure what happened here, but after 8 hours of sleep and I reload the page, it´s sorting as it should (still using Maximus2012´s example). I guess it must have been a server glitch, since I didn´t change the code while sleeping.
I´ll give creds to Maximus2012 for his quick and good responds! (and thanks to all others too ofcourse!)