I'm looking to order trophies by their type using PHP.
$trophies = $engine->query("SELECT name, detail, type FROM trophy WHERE group=:group");
$trophies->execute(array(':group'=>$group));
if($trophies->rowCount() > 0) {
while ($trophy = $trophies->fetch(PDO::FETCH_ASSOC)) {
echo $trophy['name'] . ': ' . $trophy['type'] . '<br>';
}
} else {
echo 'No trophies to be displayed.';
}
Right now, the trophies aren't being ordered.
Trophies can have the following types: platinum, gold, silver, bronze.
I would like to display platinum first, then gold, then silver and then bronze.
How can I do this? Is it possible to modify the SQL query to order the trophies to behave like the desired way?