PHP/HTML table data order by a variable?
<p>I took two datas out of my database and divided them &amp; then made $Kdr print the calculated value.</p>

<pre><code>&lt;?php
    $query = mysql_query("SELECT * FROM `high` ORDER BY `$Kdr` DESC LIMIT 20");
    while($row = mysql_fetch_array($query)){
    if ($row["kills"] != 0) {
    $Kdr = $row["kills"] / $row["deaths"];
    }       
    echo "&lt;tr&gt;&lt;td&gt;&lt;a href='personalhs.php?query={$row["playerName"]}'&gt;".$row['Runecraftlvl']."&lt;/a&gt;&lt;/td&gt;&lt;td&gt;".$row['kills']."&lt;/td&gt;&lt;td&gt;".$row['Runecraftxp']."&lt;/td&gt;&lt;td&gt;".$Kdr."&lt;/td&gt;&lt;/tr&gt;";
    }
?&gt;
</code></pre>

<p>Ignore the $row['Runecraftinglvl'], and others.</p>

<p>Basically I want my table to order data by the variable "$Kdr" I declared above that prints the divided data.</p>

<p>I tried doing this:</p>

<pre><code>    $query = mysql_query("SELECT * FROM `high` ORDER BY `" . $kdr . "` DESC LIMIT 20");
</code></pre>

<p>and this</p>

<pre><code>    $query = mysql_query("SELECT * FROM `high` ORDER BY `$Kdr` DESC LIMIT 20");
</code></pre>

<p>Both giving me this error:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/justxpp1/public_html/gxx/highscores.php on line 90</p>

<p>What am I doing wrong?
Thanks.</p>
