-
Notifications
You must be signed in to change notification settings - Fork 0
/
autocomplete.php
executable file
·48 lines (43 loc) · 1.14 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
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
include '/f5/xarxa/public/mysql.php';
include '/f5/xarxa/public/begin_caching.php';
function format($course_id){
return strtoupper(str_replace("-"," ",$course_id));
}
if (!$mysql) {
die('Could not connect: ' . mysql_error());
}
$text = $_GET["text"];
$query = "select * from courses where course_id like \"".($text)."%\" order by popularity desc limit 20";
//$query = "select * from urls";
//echo $query;
$results = array();
if($result = mysql_query($query)){
if(mysql_num_rows($result)>0){
while($row = mysql_fetch_assoc($result)){
$results[]=($row[course_id])." (".$row[name].")";
}
}
else{
$text = str_ireplace("-"," ",$text);
$query = "select * from courses where name like \"%".($text)."%\" order by popularity desc limit 20";
if($result = mysql_query($query)){
if(mysql_num_rows($result)>0){
while($row = mysql_fetch_assoc($result)){
$results[]=($row[course_id])." (".$row[name].")";
}
}
}
else{
echo "<br>$query</br>";
}
}
}
else{
echo "<br>$query</br>";
}
foreach ($results as $r){
echo "<option>$r</option>";
}
include 'f5/xarxa/public/end_caching.php';
?>