-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclassList.php
39 lines (35 loc) · 1006 Bytes
/
classList.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
<?php
include("dbpreschool.php");
//Assign the data passed from Flex to variables
$tID = mysql_real_escape_string($_GET["teacherID"]);
$query ="SELECT * ,COUNT(ID)FROM names WHERE teacher ='$tID'";
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result)){
$numberofstudents=$row['COUNT(ID)'];
}
if ($numberofstudents==0){
//Open XML
echo "<?xml version=\"1.0\"?>\n";
echo"<studentlistdata>\n";
echo"<studentlist>0</studentlist>\n";
echo"</studentlistdata>";
} else{
//Query the database to see if the given username/password combination is valid.
$query2 = "SELECT * FROM names WHERE teacher = '$tID'";
$result2 = mysql_query($query2);
//Open XML
echo "<?xml version=\"1.0\"?>\n";
echo"<studentListdata>\n";
//Create the XML
while($row = mysql_fetch_assoc($result2)){
echo"<studentlist>\n";
echo"<studentname>".$row ['name'] ."</studentname>\n";
echo"<studid>".$row['id']."</studid>\n";
echo"</studentlist>\n";
}
//Close XML
echo"</studentListdata>";
}
//Close the db
mysql_close();
?>