Jump to content

[SOLVED] math ordering numbers


Jiraiya

Recommended Posts

it didnt work this is the script i have

 

 

 

mysql_select_db("members", $con);

 

 

 

$result = mysql_query("SELECT * FROM users WHERE skill='skill' ORDER BY skill DESC");

 

echo "<table border='1'>

<tr>

<th>Name</th>

<th>Rank</th>

<th>Skill</th>

<th>Kekkei Genkai</th>

 

</tr>";

 

while($row = mysql_fetch_array($result))

  {

  echo "<tr>";

  echo "<td>" . $row['username'] . "</td>";

  echo "<td>" . $row['rank'] . "</td>";

  echo "<td>" . $row['skill'] . "</td>";

  echo "<td>" . $row['bloodline'] . "</td>";

  echo "</tr>";

  }

echo "</table>";

 

mysql_close($con);

?>

 

 

 

</body>

</html>

 

... you're using WHERE skill='skill' that means you're only retrieving values from the database where the value in the skill column is skill....

 

you then sort by skill....

 

all results have "skill" for the skill value because you specifically said those were the columns you wanted....

 

...

 

if you sort by skill where all values are skill there's no sorting to be done...

 

...

 

I really can't help you if you can't understand the problem with the logic here.

i want to display this but i want to have it in order by highest to lowest based on the skill variable

 

<th>Name</th>

<th>Rank</th>

<th>Skill</th>

<th>Kekkei Genkai</th>

 

</tr>";

 

while($row = mysql_fetch_array($result))

  {

  echo "<tr>";

  echo "<td>" . $row['username'] . "</td>";

  echo "<td>" . $row['rank'] . "</td>";

  echo "<td>" . $row['skill'] . "</td>";

  echo "<td>" . $row['bloodline'] . "</td>";

  echo "</tr>";

i tried that the page came up blank

 

 

mysql_select_db("members", $con);

 

 

SELECT * FROM users ORDER BY skill DESC

 

$result = mysql_query("SELECT * FROM users ORDER BY skill DESC");

 

echo "<table border='1'>

<tr>

<th>Name</th>

<th>Rank</th>

<th>Skill</th>

<th>Kekkei Genkai</th>

 

</tr>";

 

while($row = mysql_fetch_array($result))

  {

  echo "<tr>";

  echo "<td>" . $row['username'] . "</td>";

  echo "<td>" . $row['rank'] . "</td>";

  echo "<td>" . $row['skill'] . "</td>";

  echo "<td>" . $row['bloodline'] . "</td>";

  echo "</tr>";

  }

echo "</table>";

 

mysql_close($con);

?>

 

 

 

</body>

</html>

 

 

 

 


<?php
mysql_select_db("members", $con);
$query = "SELECT * FROM users ORDER BY skill DESC";
$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
echo "<table border='1'>
<tr>
<th>Name</th>
<th>Rank</th>
<th>Skill</th>
<th>Kekkei Genkai</th>
</tr>";
while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['username'] . "</td>";
  echo "<td>" . $row['rank'] . "</td>";
  echo "<td>" . $row['skill'] . "</td>";
  echo "<td>" . $row['bloodline'] . "</td>";
  echo "</tr>";
  }
echo "</table>";
mysql_close($con);
?>



</body>
</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.