-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetchClass.php
executable file
·52 lines (52 loc) · 1.16 KB
/
fetchClass.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
49
50
51
52
<?
include_once("databaseManager.php");
$con=new DatabaseManager();
$arr[] = array(
'courseId' =>-1,
'title' =>'选择'
);
$sql="SELECT courseId,title,days,room";
$sql.=" FROM courses";
if($_SERVER["REQUEST_METHOD"]=="GET")
{
$filter = filterStrGet();
if($filter!="")
{
$filter_json=json_decode($filter,true);
}
if($filter!='')
{
$userID=$filter_json[0]["value"];
$sql.=" where (fk_user_teacher=".$userID." AND active=1)";
}
}
// $sql.=" WHERE ( fk_user_teacher=2227 AND active=1 )";
$sql.=" ORDER BY title";
$result=$con->Query($sql);
if(mysql_num_rows($result)>0){
while($obj=mysql_fetch_object($result)){
$arr[]=$obj;
}
}
$con->Dispose();
//$arr = array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5);
Echo json_encode($arr);
function formatStr($str)
{
return trim(str_replace("'","''",$str));
}
function filterStrGet()
{
$a = explode('&',$_SERVER["REQUEST_URI"]);
$i = 0;
while ($i < count($a)) {
$b = split('=', $a[$i]);
if(htmlspecialchars(urldecode($b[0]))=="filter")
{
$filter=urldecode($b[1]);
return $filter;
}
$i++;
}
}
?>