<?php include('../include/functions.php');

$searchquery = dbEscapeString($_REQUEST['q']);
$limit = dbEscapeString($_REQUEST['limit']);
if ($searchquery == '' || ! preg_match('/[0-9]+/', $searchquery) || ! preg_match('/[0-9]+/', $limit)) {
  exit;
}

$query = "SELECT distinct(versnummer) FROM users WHERE versnummer LIKE '$searchquery%' ORDER BY versnummer ASC LIMIT 0,$limit";
$result = dbQuery($query) or error('autocomplete_versnummer.php: Cannot read users');
while ($row = dbFetchRow($result)) {
  $versnummer = $row['versnummer'];
  print $versnummer . "\n";
}
dbFreeResult($result);
