<?php
$list = "มีเครือข่ายความร่วมมือกับภาคีภายนอก เช่น มหาวิทยาลัย สถานประกอบการ หรือหน่วยงานราชการ
มีครูที่มีคุณภาพและประสบการณ์สูง บุคลากรมีความเชี่ยวชาญในสาขาวิชาที่สอน และใส่ใจนักเรียน
หลักสูตรที่ทันสมัยและเหมาะสมกับศตวรรษที่ 21 เน้นการคิดวิเคราะห์ การแก้ปัญหา และทักษะชีวิต
การใช้เทคโนโลยีสนับสนุนการเรียนการสอน มีคอมพิวเตอร์ อินเทอร์เน็ต และสื่อการสอนดิจิทัลครบถ้วน
การบริหารจัดการที่มีประสิทธิภาพ มีระบบบริหารงานที่ชัดเจน โปร่งใส และมีเป้าหมายร่วมกัน";
$mylist = preg_split('/\n/',$list);
$mykey["title"] = "ตัวอย่าง รายการจุดแข็งของโรงเรียน";
$mykey["comment"] = 5; 
$mykey["table"] = true;
function thaiall_list($mylist,$mykey){
	$j = 0;
	$txt = "<form action='' method='get'><table>";
	foreach($mylist as $list){ 
		$txt .= "<tr><td><input name=" .$j++. " type=checkbox></td><td>" . $list . " [" . $j ."]</td></tr>"; 
	}
	$txt .= "</table>";
	if(isset($mykey["comment"])) {
		$txt .= "<div style='display:table;width:99%;text-align:center;'><b>ส่วนเพิ่มเติม</b><br/><textarea name='comment' rows='". $mykey["comment"] ."' cols='40'></textarea></div>";
	}
	$txt .= "<div style='display:table;width:99%;text-align:center;' class='not_print'>
<input type=submit value=Select name=list style='background-color:blue;color:white;width:200px;height:60px;font-size:30px;'>
<input type=button value='Reset' style='background-color:blue;color:white;width:200px;height:60px;font-size:30px;' onclick=\"window.open('?','_self')\" >
</div></form>";
	if(isset($mykey["table"])) return $txt; else return "";
}
function thaiall_list_select($mylist,$mykey){
	$j = 0;
	$title = "รายการที่ถูกเลือก";
	if(isset($mykey["title"])) { $title = $mykey["title"]; }
	$txt = "<form action='' method='get'><b>$title</b><br/><table>";
	foreach($mylist as $list){
		if(isset($_REQUEST[$j++])){ $txt .= "<tr><td>✓</td><td>" . $list . "</td></tr>"; }
	}
	$txt .= "</table>";
	if(isset($mykey["comment"])) {
		$comment = str_replace("\n","<br/>",$_REQUEST["comment"]);
		$txt .= "<div style='display:table;width:98%;margin-left:auto;margin-right:auto;border:1px solid gray;'><b>ส่วนเพิ่มเติม</b><br/>" . $comment ."</div>";
	}
	$txt .= "<div style='display:table;width:99%;text-align:center;'>
<input type=button value='Back' style='background-color:blue;color:white;width:200px;height:60px;font-size:30px;' onclick=\"history.back()\" >
<input type=button value='Reset' style='background-color:blue;color:white;width:200px;height:60px;font-size:30px;' onclick=\"window.open('?','_self')\" >
</div></form>";
	if(isset($mykey["table"])) return $txt; else return "";
}
if(!isset($_SERVER["QUERY_STRING"]) && strlen($_SERVER["QUERY_STRING"]) < 3) {
	echo thaiall_list($mylist,$mykey);
} else {
	echo thaiall_list_select($mylist,$mykey);
}
?>