<?php
echo "<br />";
echo "<form method='post' action='' id='frm1' name='frm1'>";
echo "<table align='center'>";
echo "<tr>";
echo "<td>";
echo "<input type='checkbox' name='chk' onclick='Check()'>โรงเรียนอนุบาลงามจิต 2<input type='hidden' name='urlGET[]'  value='http://118.174.1.179/smss_34100055/modules/student_main/xml/student.php' disabled><br />";
echo "<input type='checkbox' name='chk' onclick='Check()'>โรงเรียนอนุบาลจิรพัฒน์<input type='hidden' name='urlGET[]'  value='http://118.174.1.179/smss_34100063/modules/student_main/xml/student.php?x=4' disabled><br />";

echo "<input type='checkbox' name='chk' onclick='Check()'>โรงเรียนxxx<input type='hidden' name='urlGET[]' value='http:///127.0.0.1/smss/modules/student_main/xml/student.php' disabled><br />";

echo "</td>";
echo "</tr>";
echo "</table>";
echo "<br />";
echo "<div align='center'><input type='submit'></div>";
echo "</form>";

if(isset($_POST['urlGET'])){
$urlGET=$_POST['urlGET'];

foreach ($urlGET as &$value) {
   		$url = $value;
		$xmlDoc = new DOMDocument();
		$xmlDoc->load($url);
		$announce = $xmlDoc->getElementsByTagName('item');
echo "<table align='center' width='65%' border='0'>";
echo "<tr><td align='center'>";
		echo base64_decode($xmlDoc->getElementsByTagName('office_code')->item(0)->nodeValue);
		echo " ";
		echo base64_decode($xmlDoc->getElementsByTagName('school_name')->item(0)->nodeValue);
		echo " ปีการศึกษา ";
		echo base64_decode($xmlDoc->getElementsByTagName('ed_year')->item(0)->nodeValue);
echo "</td></tr>";
echo "</table>";
echo "<table align='center' width='65%' border='1' borderColor='#FF0033' style='border-collapse: collapse'>";
echo "<tr align='center' bgcolor='#FBD562'><td>ที่</td><td>เลขประจำตัวประชาชน</td><td>ชื่อ</td><td>ชั้น</td></tr>";
		$i=1;
		foreach ($announce as $ann)
		{
		if(($i%2) == 0)
		$color="#CCFFFF";
		else $color="#FFFFFF";
		echo "<tr bgcolor=$color align='left'>";
			echo "<td align='center'>$i </td>";
			echo "<td align='center'>";
			echo base64_decode($ann->getElementsByTagName('person_id')->item(0)->nodeValue);
			echo "</td>";
			echo "<td>";
			echo base64_decode($ann->getElementsByTagName('prename')->item(0)->nodeValue);
			echo base64_decode($ann->getElementsByTagName('student_name')->item(0)->nodeValue);
			echo "  ";
			echo base64_decode($ann->getElementsByTagName('student_surname')->item(0)->nodeValue);
			echo "</td>";
			echo "<td>";
			echo base64_decode($ann->getElementsByTagName('class_name')->item(0)->nodeValue);
			echo "</td>";
			$i++;
		echo "</tr>";
		}
	echo "</table>";
	echo "<br>";
	}
unset($value); // break the reference with the last element
}
?>
<script>
function Check() {
		var x = document.getElementsByName("chk");
		var y = document.getElementsByName("urlGET[]");
		var i;
		for (i = 0; i < x.length; i++) {
			if (x[i].type == "checkbox") {
				if(x[i].checked == true){
				y[i].disabled=false;
				}
			}
		}	
}
</script>
