Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP Order by ASC not working on decimal type
    primarykey
    data
    text
    <p>Have a quick question regarding ORDER. I have a list of scores I am displaying in a high scores table using php. I need the lowest decimal number to display in 1st place, however when I try to use the ASC command, no results display. But if I use DESC the results do display, but in the opposite order to what I need (lowest decimal displays last).</p> <p>Here is the "working" code that displays the scores, but in the wrong order.</p> <pre><code>$query = mysql_query("select reflex,playerID from users_stats order by reflex DESC limit 10")or die(mysql_error()); $ranking = 0; while ($row = mysql_fetch_array($query)) { if ($row[reflex] &lt;= 0) break; $ranking = $ranking + 1; $rankingdisplay = doRankPosition($ranking); print "&lt;tr&gt;&lt;td&gt;&lt;b&gt;$rankingdisplay&lt;/b&gt;&lt;/td&gt;&lt;td&gt;$row[playerID]&lt;/td&gt;&lt;td&gt;$row[reflex]&lt;/td&gt;&lt;/tr&gt;"; if ($ranking &gt;= 10) break; } </code></pre> <p>Here is the code that displays nothing (no results are returned).</p> <pre><code>$query = mysql_query("select reflex,playerID from users_stats order by reflex ASC limit 10")or die(mysql_error()); $ranking = 0; while ($row = mysql_fetch_array($query)) { if ($row[reflex] &lt;= 0) break; $ranking = $ranking + 1; $rankingdisplay = doRankPosition($ranking); print "&lt;tr&gt;&lt;td&gt;&lt;b&gt;$rankingdisplay&lt;/b&gt;&lt;/td&gt;&lt;td&gt;$row[playerID]&lt;/td&gt;&lt;td&gt;$row[reflex]&lt;/td&gt;&lt;/tr&gt;"; if ($ranking &gt;= 10) break; } </code></pre> <p>I have also tried this (default);</p> <pre><code>$query = mysql_query("select reflex,playerID from users_stats limit 10")or die(mysql_error()); $ranking = 0; while ($row = mysql_fetch_array($query)) { if ($row[reflex] &lt;= 0) break; $ranking = $ranking + 1; $rankingdisplay = doRankPosition($ranking); print "&lt;tr&gt;&lt;td&gt;&lt;b&gt;$rankingdisplay&lt;/b&gt;&lt;/td&gt;&lt;td&gt;$row[playerID]&lt;/td&gt;&lt;td&gt;$row[reflex]&lt;/td&gt;&lt;/tr&gt;"; if ($ranking &gt;= 10) break; } </code></pre> <p>And again, no results display....</p> <p>The reflex score is being stored in a MySQL database using decimal(4,3) default None. Can anyone point me in the right direction? I have tried to google it, but can't seem to find anything specific to what I need. I assume it is something to do with decimal??</p> <p>Thanks in advance.</p> <p>*EDITED - I do appreciate any answers/advice, however I am very new to php and still desperately trying to learn :/</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload