-
Notifications
You must be signed in to change notification settings - Fork 1
/
autocomplete.php
35 lines (34 loc) · 1.27 KB
/
autocomplete.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
require_once("dbconfig.php");
mysql_connect($dbhost,$dbusername,$dbpassword) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());
if(isset($_POST['server']) && (isset($_POST['alliance']) || isset($_POST['player']))) {
if (isset($_POST['player'])) {
$what = mysql_real_escape_string($_POST['player']);
if(strlen($what) > 0) {
$query = mysql_query("SELECT DISTINCT player FROM `" . mysql_real_escape_string($_POST['server']) . "` WHERE `player` LIKE '" . $what . "%' LIMIT 10");
if($query) {
while ($result = mysql_fetch_array($query)) {
echo "<li onclick=\"fillplayer('" . $result['player'] . "');\">" . $result['player'] . "</li>";
}
} else {
echo 'ERROR: There was a problem with the query.';
}
}
} else {
$what = mysql_real_escape_string($_POST['alliance']);
if(strlen($what) > 0) {
$query = mysql_query("SELECT DISTINCT alliance FROM `" . mysql_real_escape_string($_POST['server']) . "` WHERE `alliance` LIKE '" . $what . "%' LIMIT 10");
if($query) {
while ($result = mysql_fetch_array($query)) {
echo "<li onclick=\"fillalliance('" . $result['alliance'] . "');\">" . $result['alliance'] . "</li>";
}
} else {
echo 'ERROR: There was a problem with the query.';
}
}
}
} else {
echo 'blah';
}
?>