Hi, anyone know how I can restrict the values displayed in a Select, taken from a MySQL query, which have been edited before output? The original values are all unique so doing a COUNT or DISTINCT in MySQL won't work. This is the PHP I'm using to pull and edit the values:
$getusers = $mysqli->query("SELECT order_discount_code FROM orders ORDER BY order_discount_code ASC");
while ($row = $getusers->fetch_assoc()) {
$vouchercode = $row['order_discount_code']; //These values are all unique but share common characters e.g the first three characters of the string
$agencycode = mb_substr($vouchercode, 0, 3); //I'm doing this as I want to have just the first three characters show in the form Select that contains this query
echo '<option>'.$agencycode.'</option>';
}
Basically I just want to output unique instances of $agencycode, so if the first three characters might be ABC, DEF or GHI for all the various records, I want ABC to only show once in the Select, DEF to show once, GHI to show once etc. At the moment my code shows a whole long list of every instance. Anyone know how I can do this? Thanks!