When I try running my code to order the sql table from largest score to smallest score it just randomly prints it.
I have tried to switch it from ASC to DESC and leave it empty but it still doesn't work.
$sql = "SELECT * FROM kids ORDER BY final";
$sqll = mysqli_query($conn, $sql);
$num = mysqli_num_rows($sqll);
while ($fin = mysqli_fetch_assoc($sqll)) {
$final = $fin['final'];
$fname = $fin['f_name'];
$lname = $fin['l_name'];
$church = $fin['churches'];
$room = $fin['room'];
$grade = $fin['grade'];
$cop = $fin['coptic'];
$mem = $fin['mem'];
$fchurch = $fin['church'];
$bible = $fin['bible'];
$fcop = "";
$fmem = "";
// find out what score
if ($cop == 100) {
$fcop = "Gold";
} elseif ($cop <= 67) {
$fcop = "silver";
} elseif ($cop <= 34) {
$fcop = "bronz";
} else {
$fcop = "";
}
//mem
if ($mem == 100) {
$fmem = "Gold";
} elseif ($mem <= 67) {
$fmem = "silver";
} elseif ($mem <= 34) {
$fmem = "bronz";
} else {
$fmem = "";
}
echo "<tr>
<th>$fname</th>
<th>$lname</th>
<th>$church</th>
<th>$grade</th>
<th>$fcop</th>
<th>$fmem</th>
<th>$bible</th>
<th>$fchurch</th>
<th>$final</th>
</tr>";
}
echo "</table>";
The result is the first person has 100 in final, then person 2 has 42, and person 3 has 49.