php - How to Set A Custom Load order For My User display Table based on Ranks -
so building new cms community , have run minor issue. want able list ranks highest in chain of command lowest, cannot work out how using string based ranks.
<?php include "dbh.php"; include "header.php"; $sql = "select * users_leo"; $result = $conn->query($sql); $row = $result->fetch_assoc(); $rank = $row["rank"]; $department = $row["department"]; ?> <div class="login-page"> </div> <div class='form'> <?php $sql = "select * users_leo"; $result = $conn->query($sql); if ($result->num_rows > 0) { echo "<table> <tr> <th>in-game name</th> <th>rank</th> <th>department</th> <th>profile</th> </tr>"; while($row = $result->fetch_assoc()) { echo "<tr>"; echo "<td>"; echo $row['username']; echo"</td>"; echo "<td>"; echo $row['username']; echo"</td>"; echo "<td>"; echo $row['department']; echo"</td>"; echo '<td><a class="viewprofile" href="profile.php?id=' . $row['id']. '"><button>view profile</button></a></td>'; echo "</tr>"; } } ?> </div> </div> </body>
as can see int below code, ranks stored strings
echo "<select name='rank'> <option value='corrections officer'>corrections officer</option> <option value='senior corrections officer'>senior corrections officer</option> <option value='doc corporal'>doc corporal</option> <option value='doc sergeant'>doc sergeant</option> <option value='doc lieutenant'>doc lieutenant</option> <option value='doc head lieutenant'>doc head lieutenant</option> <option value='doc command'>doc command</option> <option value='trooper 3rd class'>trooper 3rd class</option> <option value='trooper 2nd class'>trooper 2nd class</option> <option value='trooper 1st class'>trooper 1st class</option> <option value='lance corporal'>lance corporal</option> <option value='state corporal'>state corporal</option> <option value='state sergeant'>state sergeant</option> <option value='first sergeant'>first sergeant</option> <option value='2nd lieutenant'>2nd lieutenant</option> <option value='1st lieutenant'>1st lieutenant</option> <option value='state command'>state command</option> <option value='officer'>officer</option> <option value='senior officer'>senior officer</option> <option value='police corporal'>police corporal</option> <option value='police sergeant'>police sergeant</option> <option value='staff sergeant'>staff sergeant</option> <option value='police lieutenant'>police lieutenant</option> <option value='police head lieutenant'>police head lieutenant</option> <option value='pd command'>pd command</option> <option value='overseer'>overseer</option> </select>
i have tried , tried cannot find solution p.s. willing change ranks numbers if can explain how set displayed string.
if want select string in highest lowest order here code asc[ascending descending] , desc[descending ascending]
select * users_leo order column_name asc [or] desc;
Comments
Post a Comment