|
 |
|
ภาษา PHP ต้องการให้เลือก Dropdown list แล้วพอเอาลงดาต้าเบส แล้วมันรันค่าที่เลือก ให้ครบกับรหัสนักเรียนทุกค่า เลือกค่าเดียวแต่รันให้ครบทุกค่า |
|
 |
|
|
 |
 |
|
ภาษา PHP ต้องการให้เลือก Dropdown list แล้วพอเอาลงดาต้าเบส แล้วมันรันค่าที่เลือก ให้ครบกับรหัสนักเรียนทุกค่า เลือกค่าเดียวแต่รันให้ครบทุกค่า
Code (PHP)
<table class="table table-striped table-bordered table-hover">
<?php
$strSQL = "SELECT distinct information_student.Class_ID, information_student.classroom_id, information_student.year_id, class_student.abbreviation_class , classroom_student.classroom_name
FROM information_student, class_student, classroom_student
WHERE information_student.year_id='".$_GET['item']."' AND
information_student.Class_ID=class_student.Class_ID AND
information_student.classroom_id=classroom_student.classroom_id
ORDER BY information_student.Class_ID, information_student.classroom_id";
$objQuery = mysql_query($strSQL);
while ($row = mysql_fetch_array($objQuery)){
echo "<tr><td width='437'>".$row['abbreviation_class']."/".$row['classroom_name']."<br>";
$strSQL01 = "SELECT information_student.UserID_student, member_student.sex_student, member_student.name_student, information_student.Class_ID, information_student.classroom_id, information_student.year_id, class_student.abbreviation_class , classroom_student.classroom_name
FROM information_student, class_student, classroom_student, member_student
WHERE information_student.year_id='".$_GET['item']."' AND
information_student.UserID_student=member_student.UserID_student AND
information_student.Class_ID='".$row['Class_ID']."' AND
information_student.classroom_id='".$row['classroom_id']."' AND
information_student.Class_ID=class_student.Class_ID AND
information_student.Status_ID='1' AND
information_student.classroom_id=classroom_student.classroom_id
ORDER BY information_student.Class_ID, information_student.classroom_id";
$objQuery01 = mysql_query($strSQL01);
while ($row01 = mysql_fetch_array($objQuery01)){
echo "<input type='checkbox' name='UserID_student[".$row01['UserID_student']."]' value='". $row01['UserID_student'] ."' checked><input name='' type='text' value='".$row01['UserID_student']."' size='35'><br>";
}
echo "</td>
<td width='437'>";
echo " <select class='form-control' name='Class_ID[]'>
<option value=''>-- เลือกชั้นเรียน --</option>";
$strSQL02 = "SELECT * FROM class_student ";
$objQuery02 = mysql_query($strSQL02);
while ($row02 = mysql_fetch_array($objQuery02)){
echo "<option value='".$row02['Class_ID']."'>".$row02['Class_name']."</option>";
}
echo "</select>";
echo " <select class='form-control' name='classroom_id[]'>
<option value=''>-- เลือกห้องเรียน --</option>";
$strSQL03 = "SELECT * FROM classroom_student ";
$objQuery03 = mysql_query($strSQL03);
while ($row03 = mysql_fetch_array($objQuery03)){
echo "<option value='".$row03['classroom_id']."'>".$row03['classroom_name']."</option>";
}
echo "</select>";
echo "</td></tr>";
}
?>
<tr><td><div align="center">
<button type="button" class="btn btn-primary" onClick="history.back();">Back Button</button>
<button type="submit" class="btn btn-primary">Save Button</button>
</div></td></tr>
</table>
Code (PHP)
<?
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("plookpanya");
mysql_query("SET character_set_results=utf8");
mysql_query("SET character_set_client=utf8");
mysql_query("SET character_set_connection=utf8");
$data_h_type=(isset($_POST['UserID_student']))?$_POST['UserID_student']:NULL;
$data_more=(isset($_POST['Class_ID']))?$_POST['Class_ID']:NULL;
$data_more1=(isset($_POST['classroom_id']))?$_POST['classroom_id']:NULL;
if(count($data_h_type)>0){ // ตรวจสอบ checkbox ว่ามีการเลือกมาอย่างน้อย 1 รายการหรือไม่
foreach($data_h_type as $key=>$value){
// แสดงชุดข้อมูล ที่สอดคล้องกับ checkbox
echo $value."---".$data_more."---".$data_more1[$key]."<br>";
}
}
mysql_close($objConnect);
?>


Tag : PHP, MySQL, HTML, CSS, HTML5

|
ประวัติการแก้ไข 2019-04-29 15:36:26
|
 |
 |
 |
 |
Date :
2019-04-29 15:35:17 |
By :
aummyasia |
View :
628 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
|
|

|
Load balance : Server 04
|