diff --git a/user/assets.php b/user/assets.php index c5da6b73..9b9cc93d 100644 --- a/user/assets.php +++ b/user/assets.php @@ -136,10 +136,13 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); // OS typeahead suggestions $os_sql = mysqli_query($mysqli, "SELECT DISTINCT asset_os AS label FROM assets WHERE asset_archived_at IS NULL"); -if (mysqli_num_rows($os_sql) > 0) { - while ($row = mysqli_fetch_array($os_sql)) { - $os_arr[] = $row; - } +if ($os_sql && mysqli_num_rows($os_sql) > 0) { + $os_arr = []; + while ($row = mysqli_fetch_assoc($os_sql)) { + // jQuery UI Autocomplete expects {label: "...", value: "..."} + $label = $row['label']; + $os_arr[] = ['label' => $label, 'value' => $label]; + } $json_os = json_encode($os_arr); } @@ -373,7 +376,7 @@ if (mysqli_num_rows($os_sql) > 0) { Name - +