I took two datas out of my database and divided them & then made $Kdr print the calculated value.
<?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 "<tr><td><a href='personalhs.php?query={$row["playerName"]}'>".$row['Runecraftlvl']."</a></td><td>".$row['kills']."</td><td>".$row['Runecraftxp']."</td><td>".$Kdr."</td></tr>";
}
?>
Ignore the $row['Runecraftinglvl'], and others.
Basically I want my table to order data by the variable "$Kdr" I declared above that prints the divided data.
I tried doing this:
$query = mysql_query("SELECT * FROM `high` ORDER BY `" . $kdr . "` DESC LIMIT 20");
and this
$query = mysql_query("SELECT * FROM `high` ORDER BY `$Kdr` DESC LIMIT 20");
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
What am I doing wrong? Thanks.
";` – Chris Forrence Jan 28 '13 at 21:18