|
 |
|
การ checkbox เลือกนักศึกษา คือว่าตอนนี้ต้องการเลือกนักศึกษาในระบบโดยใช้ checkbox อะค่ะ |
|
 |
|
|
 |
 |
|
ฮ่วย แล่วๆ แล่วๆ แล้วแล้ว
ใช้ utf-8 ก็ดีนะชีวิตจะได้ไม่ยุ่งยากภายหลัง
เอาไปประยุกต์เอาเด้อ
file name : checkbox1.html
Code (PHP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form action="checkbox2.php" method="post">
<input type="checkbox" name="chkLanguage[]" value="1">PHP <br/>
<input type="checkbox" name="chkLanguage[]" value="2">.NET <br/>
<input type="checkbox" name="chkLanguage[]" value="3">Java <br/>
<input type="checkbox" name="chkLanguage[]" value="4">Perl <br/>
<input name="submit" type="submit" value="submit" />
</form>
</body>
</html>
file name : checkbox2.php
Code (PHP)
<?php
for($i=0;$i<count($_POST["chkLanguage"]);$i++){
$chk_id ="";
if($i < count($_POST["chkLanguage"])-1){ $comma = ","; }else{ $comma ="";}
if(trim($_POST["chkLanguage"][$i]) != ""){
$chk_id .= $_POST["chkLanguage"][$i].$comma;
}
echo $chk_id; // เอา id ตัวนี้ไป เป็น parameter ในเงื่อนไข where
}
// ก็เรียกข้อมูลจาก database มา show
/*
$sql = "select id, x, y , z form tb_xyz WHERE id IN($chk_id) ";
$result = mysql_query($sql);
while($row=mysql_fetch_array($result){
// อะไรก็ว่าไป
}
*/
?>
|
 |
 |
 |
 |
Date :
2010-03-10 12:21:01 |
By :
peterxp |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|