|
 |
|
จะทำยังไงให้คลิกที่ปุ่มบันทึกแล้วมันเพิ่มข้อมูลให้ค่ะ พอดีใช้จาวาสคริปแล้วมันรันกลับมาหน้า page อะค่ะ |
|
 |
|
|
 |
 |
|
โค๊ดเปนงี้ค่ะ
Code
<?
include'connect2.php';
if($_POST)
{
$groups_num = $_POST["groups_num"];
$std_id = $_POST["std_id"];
$company_id = $_POST['company_id'];
$position = $_POST["position"];
$points = $_POST["points"];
$sql = "insert into register(register_id,groups_num,std_id,company_id,position,points)";
$sql.= "values('0','$groups_num','$std_id','$company_id','$position','$points')";
$result = mysql_query($sql,$conn);
if($result)
{
echo "<script>alert('ข้อมูลถูกบันทึกแล้ว' );
window.location='index_teacher.php';</script>";
}
else
{
echo mysql_error();
}
}
?>
<script language="JavaScript">
function resutGroups(GroupsID)
{
switch(GroupsID)
{
<?
$strSQL = "SELECT * FROM groups";
$objQuery = mysql_query($strSQL);
while($objResult = mysql_fetch_array($objQuery))
{
?>
case "<?=$objResult["groups_num"];?>":
frmMain.txtGroups.value = "<?=$objResult["groups"];?>";
frmMain.txtSubID.value = "<?=$objResult["sub_id"];?>";
frmMain.txtSubName.value = "<?=$objResult["sub_name"];?>";
frmMain.txtMajor.value = "<?=$objResult["major"];?>";
frmMain.txtTerm.value = "<?=$objResult["term"];?>";
frmMain.txtYear.value = "<?=$objResult["year"];?>";
break;
<?
}
?>
default:
frmMain.txtGroups.value = "";
}
}
</script>
<script language="JavaScript">
function resutStd(StdD)
{
switch(StdID)
{
<?
$strSQL = "SELECT * FROM student";
$objQuery = mysql_query($strSQL);
while($objResult = mysql_fetch_array($objQuery))
{
?>
case "<?=$objResult["std_id"];?>":
frmMain.txtStdName.value = "<?=$objResult["std_name"];?>";
break;
<?
}
?>
default:
frmMain.txtStdName.value = "";
}
}
</script>
<script language="JavaScript">
function resutCompany(CompanyID)
{
switch(CompanyID)
{
<?
$strSQL = "SELECT * FROM company";
$objQuery = mysql_query($strSQL);
while($objResult = mysql_fetch_array($objQuery))
{
?>
case "<?=$objResult["company_id"];?>":
frmMain.txtCompanyName.value = "<?=$objResult["company_name"];?>";
break;
<?
}
?>
default:
frmMain.txtCompanyName.value = "";
}
}
</script>
<form action="page.php" method="post" name="frmMain">
<table width="651" height="537" border="0">
<tr>
<td height="89" colspan="4" align="center"><span class="head_submit">การลงทะเบียน</span></td>
</tr>
<tr>
<td align="right">เลขที่หมู่ : </td>
<td><select name="groups_num" onchange="resutGroups(this.value);">
<option value=""><-- กรุณาเลือกเลขที่หมู่ --></option>
<?
$strSQL = "SELECT * FROM groups";
$objQuery = mysql_query($strSQL);
while($objResult = mysql_fetch_array($objQuery))
{
?>
<option value="<?=$objResult["groups_num"];?>">
<?=$objResult["groups_num"];?>
</option>
<?
}
?>
</select></td>
<td align="right">หมู่ :</td>
<td><input name="txtGroups" type="text" value="" size="15" /></td>
</tr>
<tr>
<td align="right">รหัสวิชา : </td>
<td><input name="txtSubID" type="text" value="" size="15" /></td>
<td align="right">ชื่อวิชา : </td>
<td><input name="txtSubName" type="text" value="" size="25" /></td>
</tr>
<tr>
<td align="right">ปีการศึกษา : </td>
<td><input name="txtYear" type="text" value="" size="10" /></td>
<td align="right">ภาคเรียนที่ : </td>
<td><input name="txtTerm" type="text" value="" size="10" /></td>
</tr>
<tr>
<td align="right">สาขาวิชา : </td>
<td><input name="txtMajor" type="text" value="" size="23" /></td>
</tr>
<tr>
<td align="right">รหัสนักศึกษา : </td>
<td><select name="std_id" onchange="resutStd(this.value);">
<option value=""><-- กรุณาเลือกรหัสนักศึกษา --></option>
<?
$strSQL = "SELECT * FROM student";
$objQuery = mysql_query($strSQL);
while($objResult = mysql_fetch_array($objQuery))
{
?>
<option value="<?=$objResult["std_id"];?>">
<?=$objResult["std_id"];?>
</option>
<?
}
?>
</select></td>
<td align="right">ชื่อนักศึกษา : </td>
<td><input name="txtStdName" type="text" value="" size="30" /></td>
</tr>
<tr>
<td align="right">รหัสหน่วยงาน : </td>
<td><select name="company_id" onchange="resutCompany(this.value);">
<option value=""><-- กรุณาเลือกรหัสหน่วยงาน --></option>
<?
$strSQL = "SELECT * FROM company";
$objQuery = mysql_query($strSQL);
while($objResult = mysql_fetch_array($objQuery))
{
?>
<option value="<?=$objResult["company_id"];?>">
<?=$objResult["company_id"];?>
</option>
<?
}
?>
</select></td>
<td align="right">ชื่อหน่วยงาน : </td>
<td><input name="txtCompanyName" type="text" value="" size="30" /></td>
</tr>
<tr>
<td align="right">สถานะฝึกประสบการณ์ :</td>
<td colspan="3"><label for="select"></label>
<label>
<input name="position" type="radio" id="position_0" value="ฝึกประสบการณ์วิชาชีพ" />
ฝึกประสบการณ์วิชาชีพ</label>
<label>
<input type="radio" name="position" value="ยังไม่ฝึกประสบการณ์วิชาชีพ" id="position_1" />
ยังไม่ฝึกประสบการณ์วิชาชีพ</label></td>
</tr>
<tr>
<td align="right">คะแนนฝึกประสบการณ์ : </td>
<td><input name="points" type="text" id="points" size="15" /></td>
</tr>
<tr>
<td height="78" colspan="4" align="center"><input type="submit" name="button" id="button" value="บันทึก" />
<input type="reset" name="button2" id="button2" value="เคลียร์" /></td>
</tr>
</table>
<p> </p>
</form>
หน้าจอค่ะ

Tag : PHP

|
|
 |
 |
 |
 |
Date :
2012-07-25 00:27:59 |
By :
cutefulllifehoney@gm |
View :
1149 |
Reply :
5 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อธิบายเพิ่มเติมครับ
|
 |
 |
 |
 |
Date :
2012-07-25 17:14:14 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่เป็นไรค่ะๆ ทำได้แล้วค่ะ 
|
 |
 |
 |
 |
Date :
2012-07-25 23:19:59 |
By :
cutefulllifehoney@gm |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตกลงแก้ยังไงครับ
|
 |
 |
 |
 |
Date :
2012-07-26 06:05:02 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อยากรู้ด้วยครับ แบ่งปันบ้าง
|
 |
 |
 |
 |
Date :
2012-07-26 09:11:52 |
By :
apisitp |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ก็สร้างไฟล์ php ขึ้นมาอิกไฟล์หนึ่ง ตั้งชื่อว่า page.php แล้วก้อใส่โค๊ดเพิ่มข้อมูลลงไปในหน้านั้นค่ะ พอคลิกปลุ่มตกลงมันก้อรันไปทำหน้า page.php แล้วค่ะ มันก้อบันทึกให้เลย
|
 |
 |
 |
 |
Date :
2012-07-28 10:24:57 |
By :
cutefulllifehoney@gm |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|