|
 |
|
ผมต้องเขียนการบันทึกลงข้อมูลยังไงครับ.....ตอนนี้ผมมีช่องกรอกข้อมูลอยู่ 2 ช่อง ๆ แรกคือ ชื่อ ช่อง 2 คือ รายละเอียด |
|
 |
|
|
 |
 |
|
ตอนนี้ผมมีช่องกรอกข้อมูลอยู่ 2 ช่อง ๆ แรกคือ ชื่อ ช่อง 2 คือ รายละเอียด

คือผมต้องการกดที่ปุ่มแล้วให้บันทึกช่อง 2 ช่องลงไปที่ฐานข้อมูล ผมบันทึกยังไงก็ลงไปแค่ช่องเดียวครับ คือช่อง name แต่ช่อง detail ไม่ลงครับ
โค้ด
Code (PHP)
<tr bgcolor="#E6E6E6">
<td width="30">à¾ÔèÁ</td>
<td><input name="name" type="text" class="textinput" id="name" style="width:100%"></td>
<td><input name="deatail" type="text" class="textinput" id="detail" style="width:100%"></td>
<td width="50"><input type="button" name="Button" value="à¾ÔèÁ" class="btnew" style="width:100%" onClick="window.open('admin_school_save.php?name='+document.getElementById('name').value,'xData','');"></td>
</tr>
ส่วนของตัวรับเมื่อกดปุ่มครับ
Code (PHP)
<?
session_start();
include('connectdb.php');
include('config.php');
include('function.php');
?>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<?
if($id<1){
if($name=="") err('name !!','errtxt');
if($detail=="") err('deatail !!','errtxt');
$schoolsSQL = "select * from schools where sch_name='".trim($name)."'";
$schoolsQRY = mysql_db_query($dbname, $schoolsSQL);
if(mysql_num_rows($schoolsQRY)>0) err('name!!','errtxt');
$schoolsSQL = "insert into schools set
sch_detail='$detail',
sch_name='$name'";
mysql_db_query($dbname, $schoolsSQL);
$sch = mysql_insert_id();
//เพิ่้ม user 1 คน
$password = md5("sch".get_number($sch,4));
$usersSQL = "insert into users set
u_type='user',
u_schid='$sch',
u_name='admin',
u_username='bblmd".get_number($sch,4)."',
u_password='".$password."',
u_status='1'";
mysql_db_query($dbname, $usersSQL);
echo "<script>window.parent.document.getElementById('name').value=''; window.parent.dozone('admin_school_list','showlist');</script>";
} else {
if($name=="") { alert('name !!'); exit(); }
if($detail=="") { alert('detail !!'); exit(); }
$schoolsSQL = "select * from schools where sch_name='".trim($name)."' and sch_id!='".$id."'";
$schoolsQRY = mysql_db_query($dbname, $schoolsSQL);
if(mysql_num_rows($schoolsQRY)>0) { alert('name!!'); exit(); }
$schoolsSQL = "update schools set
sch_detail='$detail',
sch_name='$name'
where sch_id='".$id."'";
mysql_db_query($dbname, $schoolsSQL);
err('<font color=green>บันทึกแล้ว</font>','errtxt');
}
?>
Tag : PHP

|
|
 |
 |
 |
 |
Date :
2014-10-12 00:44:39 |
By :
phuttawat |
View :
660 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ทำได้แล้วครับ ขอบคุณครับ
|
 |
 |
 |
 |
Date :
2014-10-12 01:00:05 |
By :
phuttawat |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

|
 |
 |
 |
 |
Date :
2014-10-12 18:56:05 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|