|
|
|
มีเรื่องรบกวนพี่ๆกูรูอีกแล้วครับ เป็นระบบจัดการ เพิ่มลบแก้ไขครับ |
|
|
|
|
|
|
|
เป็นระบบจัดการ เพิ่ม ลบ แก้ไข ฐานข้อมูลอ่ะครับ คือตอนทดสอบในเครื่อง ใช้ Localhost ก็ทำงานปกติครับ แต่พออัพขึ้นโฮตส์ ดันไม่ทำงานอ่ะครับ โค๊ดจะมีหน้าเดียวครับ รบกวนหนอ่ยครับ
Code (PHP)
<? include_once "connDB.php"; ?>
<?
if($submit=="OK"){
if($id1==""){
$sql="INSERT INTO tbl_admin set Auto_ID='".$Auto_ID."',User_ID='".$User_ID."',Password='".$Password."',Gender='".$Gender."',Title_Name='".$Title_Name."',FirstName='".$FirstName."',LastName='".$LastName."',User_type='".$User_type."',Position='".$Position."',Department='".$Department."',Email='".$Email."',Tel='".$Tel."',Remark='".$Remark."'";
mysql_query($sql);
}else{
$sql="UPDATE tbl_admin set User_ID='".$User_ID."',Password='".$Password."',Gender='".$Gender."',Title_Name='".$Title_Name."',FirstName='".$FirstName."',LastName='".$LastName."',User_type='".$User_type."',Position='".$Position."',Department='".$Department."',Email='".$Email."',Tel='".$Tel."',Remark='".$Remark." ' WHERE Auto_ID='".$id1."'" ;
mysql_query($sql);
}
}
if ($submit=="DEL"){
$sql="delete from tbl_admin where Auto_ID ='".$id1."'";
mysql_query($sql);
}
?>
<script language="JavaScript">
function chkdel(){
if(confirm(' กรุณายืนยันการลบอีกครั้ง !!! ')){
return true;
}else{
return false;
}
}
function Check_txt(){
if(document.getElementById('Password').value==""){
alert("กรุณาระบุ Password ด้วยครับ");
document.getElementById('Password').focus();
return false;
}
if(document.getElementById('Title_Name').value==""){
alert("กรุณาระบุ Title_Name ด้วยครับ");
document.getElementById('Title_Name').focus();
return false;
}
if(document.getElementById('FirstName').value==""){
alert("กรุณาระบุ FirstName ด้วยครับ");
document.getElementById('FirstName').focus();
return false;
}
if(document.getElementById('LastName').value==""){
alert("กรุณาระบุ LastName ด้วยครับ");
document.getElementById('LastName').focus();
return false;
}
if(document.getElementById('Position').value==""){
alert("กรุณาระบุ Position ด้วยครับ");
document.getElementById('Position').focus();
return false;
}
if(document.getElementById('Department').value==""){
alert("กรุณาระบุ Department ด้วยครับ");
document.getElementById('Department').focus();
return false;
}
}
</script>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />-->
<title>PHP CODE FATHER 2009</title>
<link href="style/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<center>
<div id="container">
<div id="header">
<div id="header_left"></div>
<div id="header_main">ระบบจัดการข้อมูล DBMS OONRAK-KOH SAMUI SCHOOL</div>
<div id="header_right"></div>
</div>
<div id="content"><br><br>
<? if($submit=="" or $show=="OK"){?>
<center><form name="form1" method="post" action="admin.php?show=OK&strSearch=Y">
<table width="50%" >
<tr>
<td width="36%"><div align="right">ค้นหา :<select name="Search2">
<option value="Password" <? if($Search2=="Password"){ ?>selected<? }?>>Password</option>
<option value="Title_Name" <? if($Search2=="Title_Name"){ ?>selected<? }?>>Title_Name</option>
<option value="FirstName" <? if($Search2=="FirstName"){ ?>selected<? }?>>FirstName</option>
<option value="LastName" <? if($Search2=="LastName"){ ?>selected<? }?>>LastName</option>
<option value="Position" <? if($Search2=="Position"){ ?>selected<? }?>>Position</option>
<option value="Department" <? if($Search2=="Department"){ ?>selected<? }?>>Department</option>
</select></div>
</td>
<td width="64%"><input name="Search" type="text" size="20" value="<? echo $Search?>"onFocus="this.value = '';">
<input type="submit" name="submit" value="Search">
</td>
</tr>
</table>
</form></center>
<?
if(!isset($start)){
$start = 0;
$page=1;
}
$limit = '15';
if($strSearch=="Y"){
$Qtotal = mysql_query("select * from tbl_admin Where ".$Search2." like '%".$Search."%' ");
}else{
$Qtotal = mysql_query("select * from tbl_admin");
}
$total = mysql_num_rows($Qtotal);
if($strSearch=="Y"){
$Query = mysql_query("select * from tbl_admin Where ".$Search2." like '%".$Search."%' order by Auto_ID DESC LIMIT $start,$limit");
}else{
$Query= mysql_query("select * from tbl_admin order by Auto_ID DESC LIMIT $start,$limit");
}
$totalp = mysql_num_rows($Query);
$xx=$totalp+$start;
$yy=$start+1;
echo "ข้อมูลที่ ".$yy." ถึงข้อมูลที่ ".$xx;
printf(" | จากทั้งหมด %d รายการ ",$total);
printf(" | หน้าที่ %d <br />",$page);
?><br><br>
<table width="98%">
<tr bgcolor="#999999" height="40" onmouseover="this.style.backgroundColor='#CCFFCC'" onmouseout="this.style.backgroundColor=''">
<td ><strong>UserID </strong></td>
<td ><strong>Password </strong></td>
<td ><strong>Title_Name </strong></td>
<td ><strong>FirstName </strong></td>
<td ><strong>LastName </strong></td>
<td ><strong>Position </strong></td>
<td ><strong>Department </strong></td>
<td width="8%"><a href="admin.php?submit=Add&show="><center><img src="style/images/add.png" border="0"></center></a></td>
</tr>
<?
while($arr = mysql_fetch_array($Query)){
$autoid = $arr['Auto_ID'];
$i++;
if($i%2==0){
$bg = "#CCCCCC";
}else{
$bg = "#FFFFFF";
}
?>
<tr bgcolor="<? echo $bg?>" onmouseover="this.style.backgroundColor='#CCFFCC'" onmouseout="this.style.backgroundColor=''" valign="top">
<td><? echo $arr['User_ID'] ?></td>
<td><? echo $arr['Password'] ?></td>
<td><? echo $arr['Title_Name'] ?></td>
<td><? echo $arr['FirstName'] ?></td>
<td><? echo $arr['LastName'] ?></td>
<td><? echo $arr['Position'] ?></td>
<td><? echo $arr['Department'] ?></td>
<td align="right">
<a href="admin.php?submit=DEL&show=OK&id1=<? echo $autoid;?>" OnClick="return chkdel();"><img src="style/images/-.png" border="0"></a>
<a href="admin.php?submit=Edit&id1=<? echo $autoid;?>"><img src="style/images/Tools.png" border="0"></a>
</td>
</tr>
<? }?>
</table>
<? }?>
<? if($submit=="Add"){?>
<form action="admin.php?submit=OK&show=OK&id1=" method="post"onSubmit="return Check_txt()">
<table width="98%">
<tr>
<td width="30%">Auto_ID</td>
<td width="70%"><input name="Auto_ID" id="Auto_ID" type="text" size="50"></td>
</tr>
<tr>
<td width="30%">User_ID</td>
<td width="70%"><input name="User_ID" id="User_ID" type="text" size="50"> * </td>
</tr>
<tr>
<td width="30%">Password</td>
<td width="70%"><input name="Password" id="Password" type="text" size="50"> * </td>
</tr>
<tr>
<td width="30%">Gender</td>
<td width="70%"><input name="Gender" id="Gender" type="text" size="50"></td>
</tr>
<tr>
<td width="30%">Title_Name</td>
<td width="70%"><input name="Title_Name" id="Title_Name" type="text" size="50"> * </td>
</tr>
<tr>
<td width="30%">FirstName</td>
<td width="70%"><input name="FirstName" id="FirstName" type="text" size="50"> * </td>
</tr>
<tr>
<td width="30%">LastName</td>
<td width="70%"><input name="LastName" id="LastName" type="text" size="50"> * </td>
</tr>
<tr>
<td width="30%">User_type</td>
<td width="70%"><input name="User_type" id="User_type" type="text" size="50"></td>
</tr>
<tr>
<td width="30%">Position</td>
<td width="70%"><input name="Position" id="Position" type="text" size="50"> * </td>
</tr>
<tr>
<td width="30%">Department</td>
<td width="70%"><input name="Department" id="Department" type="text" size="50"> * </td>
</tr>
<tr>
<td width="30%">Email</td>
<td width="70%"><input name="Email" id="Email" type="text" size="50"></td>
</tr>
<tr>
<td width="30%">Tel</td>
<td width="70%"><input name="Tel" id="Tel" type="text" size="50"></td>
</tr>
<tr>
<td width="30%">Remark</td>
<td width="70%"><input name="Remark" id="Remark" type="text" size="50"></td>
</tr>
<tr height="50">
<td></td>
<td align="left" valign="middle"><input type="submit" name="Submit" value=" บันทึก "> <input type="reset" name="Submit2" value="ล้างข้อมูล"> <input type="button" name="Submit222" value=" ยกเลิก " onclick="document.location.href='admin.php?show=OK'"></td>
</tr>
</table>
</form>
<? }?>
<? if($submit=="Edit"){
$sql="select * from tbl_admin where Auto_ID =".$id1." ";
$tem = mysql_query($sql);
$row3=mysql_fetch_array($tem);
?>
<form action="admin.php?submit=OK&show=OK&id1=<? echo $id1?>" method="post"onSubmit="return Check_txt();">
<table width="98%">
<tr>
<td width="30%">Auto_ID</td>
<td width="70%"><input name="Auto_ID" id="Auto_ID" type="text" size="50" value="<? echo $row3['Auto_ID'] ?>"></td>
</tr>
<tr>
<td width="30%">User_ID</td>
<td width="70%"><input name="User_ID" id="User_ID" type="text" size="50" value="<? echo $row3['User_ID'] ?>"></td>
</tr>
<tr>
<td width="30%">Password</td>
<td width="70%"><input name="Password" id="Password" type="text" size="50" value="<? echo $row3['Password'] ?>"> * </td>
</tr>
<tr>
<td width="30%">Gender</td>
<td width="70%"><input name="Gender" id="Gender" type="text" size="50" value="<? echo $row3['Gender'] ?>"></td>
</tr>
<tr>
<td width="30%">Title_Name</td>
<td width="70%"><input name="Title_Name" id="Title_Name" type="text" size="50" value="<? echo $row3['Title_Name'] ?>"> * </td>
</tr>
<tr>
<td width="30%">FirstName</td>
<td width="70%"><input name="FirstName" id="FirstName" type="text" size="50" value="<? echo $row3['FirstName'] ?>"> * </td>
</tr>
<tr>
<td width="30%">LastName</td>
<td width="70%"><input name="LastName" id="LastName" type="text" size="50" value="<? echo $row3['LastName'] ?>"> * </td>
</tr>
<tr>
<td width="30%">User_type</td>
<td width="70%"><input name="User_type" id="User_type" type="text" size="50" value="<? echo $row3['User_type'] ?>"></td>
</tr>
<tr>
<td width="30%">Position</td>
<td width="70%"><input name="Position" id="Position" type="text" size="50" value="<? echo $row3['Position'] ?>"> * </td>
</tr>
<tr>
<td width="30%">Department</td>
<td width="70%"><input name="Department" id="Department" type="text" size="50" value="<? echo $row3['Department'] ?>"> * </td>
</tr>
<tr>
<td width="30%">Email</td>
<td width="70%"><input name="Email" id="Email" type="text" size="50" value="<? echo $row3['Email'] ?>"></td>
</tr>
<tr>
<td width="30%">Tel</td>
<td width="70%"><input name="Tel" id="Tel" type="text" size="50" value="<? echo $row3['Tel'] ?>"></td>
</tr>
<tr>
<td width="30%">Remark</td>
<td width="70%"><input name="Remark" id="Remark" type="text" size="50" value="<? echo $row3['Remark'] ?>"></td>
</tr>
<tr height="50">
<td></td>
<td><input type="submit" name="Submit" value=" บันทึก "> <input type="button" name="Submit222" value=" ยกเลิก " onclick="document.location.href='admin.php?show=OK'"></td>
</tr>
</table>
</form>
<? }?>
</div>
<div id="footer">
<? if($submit=="" or $show=="OK"){
$page = ceil($total/$limit);
for($i=1;$i<=$page;$i++){
if($_GET['page']==$i){
echo "[<a href='?start=".$limit*($i-1)."&page=$i&strSearch=$strSearch&Search=$Search&Search2=$Search2'><B>$i</B></A>]";
}else{
echo "[<a href='?start=".$limit*($i-1)."&page=$i&strSearch=$strSearch&Search=$Search&Search2=$Search2'>$i</A>]";
}}} ?>
</div>
</div>
</center>
</body>
เป็นหาคือ ทดลอง เมื่อคลิกเพิ่มจะนิ่งไม่ไปที่ฟังก์ชั่นของการเพิ่ม อ่ะครับ ก็ไม่ทำงาน่อะครับ แก็ไขก็ไม่ไปหน้าแก้ไขเมื่อคลิกแก้ไข
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2010-09-30 15:55:00 |
By :
ก้าวแรกPHP |
View :
841 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ยังไม่ได้เลยครับพี่วิน
|
|
|
|
|
Date :
2010-09-30 16:38:24 |
By :
ก้าวแรกPHP |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|