How can i sort my result values? With the highest entry on top of my table first

124
September 07, 2019, at 8:50 PM

I want to display my records with the highest entry on top first.

$sql1 = $mysqli->query("SELECT keyword_id, info FROM keywords where sid = '8'");
while ($row1 = $sql1->fetch_assoc()) {
$keywordID = $row1['kid'];
$keywordInfo = $row1['info'];
$sql2 = $mysqli->query("SELECT count(*) as totalcandidatevote from entries where kid = '$keywordID' && sid = '$sid' order by COUNT(*) DESC");
while ($row2 = $sql2->fetch_assoc()) {
$totalVote = $row2['totalcandidatevote']; ?>
<tr>
 <td>
  <?php
  if ($overallVote === '0') {
   echo ' ';
  } else {
    $percentage = round($totalVote / ($overallVote / 100), 2);
    echo $percentage.'%';
  }
  ?>
 </td>
 <td><?php echo $keywordInfo; ?></td>
 <td><?php echo $totalVote; ?></td>
</tr>
}
}

The output in my table is like this:

1%      Sample 1      1
80%     Sample 2      5
19%     Sample 3      3

What i want is:

80%     Sample 2     5
19%     Sample 3     3
1%      Sample 1     1
READ ALSO
In jupyter notebook, I commented my variable, however instead of a &#39;variable is not defined error&#39; I still get value output

In jupyter notebook, I commented my variable, however instead of a 'variable is not defined error' I still get value output

In a jupyter notebook, what is the reason when I commented a variable declaration and trying to call it, instead of getting a 'variable is not defined error' , I get the output before I commented that variable?

89
How to correctly check for two conditions?

How to correctly check for two conditions?

I am working on a homework problemI want that calling this function: numberConverter([1,2,3,'4','5', {}, 33])

111