im sure this would be a simple fix but im lost as to where to place the sort function in this.
<select class="form-control" name="unit"><option></option>
<?php
$query=mysqli_query($db, "SELECT * FROM units") or die(mysqli_error($db));
while($row=mysqli_fetch_array($query))
{
if(!in_array($row["id"], $units)){?>
<option value="<?php echo $row["id"];?>"><?php echo $row["unitsn"];?></option>
You can add ordering to your MySQL query, like so:
$query=mysqli_query($db, "SELECT * FROM units ORDER BY unitsn DESC") or die(mysqli_error($db));
For fields that are strings in MySQL, the default ordering method is alphabetical.