Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > รบกวนดู code ให้หน่อยครับทำหน้า แก้ไข กับ ลบในหน้าเดิม



 

รบกวนดู code ให้หน่อยครับทำหน้า แก้ไข กับ ลบในหน้าเดิม

 



Topic : 078406



โพสกระทู้ ( 113 )
บทความ ( 0 )



สถานะออฟไลน์




รบกวนดู code ให้หน่อยครับทำหน้า แก้ไขกับลบ ในหน้าเดิม คือว่าทำเป็นหน้า edit พนักงานอะครับ

ผมกำหนดให้ มันโชว์หน้าละ 5 รายชื่อ ทีนี้พอผมทำการ แก้ไขหน้าแรกก็จะแก้ไขได้ปกติ แต่พอจะแก้ไขข้อมูลในหน้าที่ 2 พอกดปุ่มมันจะ

เด้งมาหน้าแรกเลยครับ ผมรู้ว่ามันหน้าจะเป็นที่ page ซึ่งไม่ได้ระบุมันเลยไม่สามารถทำที่หน้า 2 ได้ แล้วจะระบุมันยังไงดีครับ

Code (PHP)
<html>
<head>
<!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" />
</head>
<body>
<?php



//*** code แสดงน่าตามจำนวน ***//

$strSQL = "SELECT * FROM employee ";
$objQuery = mysql_query($strSQL) or die (mysql_error() );
$Num_Rows = mysql_num_rows($objQuery);

$Per_Page = 5;   // Per Page
$Page = $_GET["Page"];
if(!$_GET["Page"])
{
$Page=1;
}
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($Num_Rows<=$Per_Page)
{
$Num_Pages =1;
}
else if(($Num_Rows % $Per_Page)==0)
{
$Num_Pages =($Num_Rows/$Per_Page) ;
}
else
{
$Num_Pages =($Num_Rows/$Per_Page)+1;
$Num_Pages = (int)$Num_Pages;
}



//*** Update Condition ***//
if($_POST["hdnCmd"] == "Update")
{
	$strSQL = "UPDATE employee SET ";
	$strSQL .="employee_id = '".$_POST["txtEditemployee_id"]."' ";
	$strSQL .=",personalgrade = '".$_POST["txtEditpersonalgrade"]."' ";
	$strSQL .=",title = '".$_POST["txtEdittitle"]."' ";
	$strSQL .=",f_name = '".$_POST["txtEditf_name"]."' ";
	$strSQL .=",l_name = '".$_POST["txtEditl_name"]."' ";
	$strSQL .=",email = '".$_POST["txtEditemail"]."' ";
	$strSQL .=",personal_type = '".$_POST["txtEditpersonal_type"]."' ";
	$strSQL .=",affiliation = '".$_POST["txtEditaffiliation"]."' ";
	$strSQL .=",user_log = '".$_POST["txtEdituser_log"]."' ";
	$strSQL .=",pass_log = '".$_POST["txtEditpass_log"]."' ";
	$strSQL .="WHERE employee_id = '".$_POST["hdnEditCustomerID"]."' ";
	$objQuery = mysql_query($strSQL) or die(mysql_error());

	//header("location:$_SERVER[PHP_SELF]");
	//exit();
}

//*** Delete Condition ***//
if($_GET["Action"] == "Del")
{
	$strSQL = "DELETE FROM employee ";
	$strSQL .="WHERE employee_id = '".$_GET["employee_id"]."' ";
	$objQuery = mysql_query($strSQL);

	//header("location:$_SERVER[PHP_SELF]");
	//exit();
}
//echo $strSQL;
//exit;
?>


<form name="frmMain" method="post" action="<?php echo $_SERVER["PHP_SELF"];?>?page=manage_user">
<!--Code ตารางและสี -->
<style type="text/css">
	table.coll 
	{
	border-collapse: collapse
	}
	tr:nth-child(even) { background-color:#b2d281; }
    tr:nth-child(odd) { background-color:#FFF; }
    tr:first-child {background-color:#4682b4;}
</style>

<input type="hidden" name="hdnCmd" value="">
<table class="coll" cellpadding="1" cellspacing="1" width="1200" border="1" >

  <tr>
    <th width="91" height="30"> <div align="center"><font color="white"> รหัสพนักงาน</div></th>
    <th width="98"> <div align="center"><font color="white">  ตำแหน่ง </div></th></font>
    <th width="80"> <div align="center"> <font color="white"> คำนำหน้า </div></th></font>
    <th width="100"> <div align="center"><font color="white">  ชื่อ </div></th></font>
    <th width="100"> <div align="center"><font color="white">   นามสกุล </div></th></font>
    <th width="200"> <div align="center"><font color="white">  อีเมล์ </div></th></font>
    <th width="80"> <div align="center"><font color="white">  ประเภทผู้ใช้ </div></th></font>
    <th width="80"> <div align="center"><font color="white">  สังกัด </div></th></font>
	<th width="80"> <div align="center"><font color="white">  Username </div></th></font>
    <th width="80"> <div align="center"><font color="white">  Password </div></th></font>
    <th width="30"> <div align="center"><font color="white">  แก้ไข </div></th></font>
    <th width="30"> <div align="center"><font color="white">  ลบ </div></th></font>
  </tr>

<?php
$strSQL = "SELECT * FROM employee order  by employee_id ASC LIMIT $Page_Start , $Per_Page";
$objQuery = mysql_query($strSQL) or die (mysql_error() );
//$strSQL = "SELECT * FROM employee";
//$objQuery = mysql_query($strSQL) or die (mysql_error() );
while($objResult = mysql_fetch_array($objQuery) )
{
?>

  <?php
	if($objResult["employee_id"] == $_GET["employee_id"] and $_GET["Action"] == "Edit")
	{
  ?>
  <tr>
    <td height="37"><div align="center">
	<input type="text" name="txtEditemployee_id" size="7" value="<?php echo $objResult["employee_id"];?>">
    <input type="hidden" name="hdnEditCustomerID" size="10" value="<?php echo $objResult["employee_id"];?>" />
    </div></td>
    <td align="center"><input type="text" name="txtEditpersonalgrade" size="8" value="<?php echo $objResult["personalgrade"];?>" /></td>
    <td align="center"><input type="text" name="txtEdittitle" size="5" value="<?php echo $objResult["title"];?>" /></td>
    <td><div align="center">
    <input type="text" name="txtEditf_name" size="10" value="<?php echo $objResult["f_name"];?>" />
    </div></td>
    <td align="center"><input type="text" name="txtEditl_name" size="10" value="<?php echo $objResult["l_name"];?>" /></td>
    <td align="center"><input type="text" name="txtEditemail" size="25" value="<?php echo $objResult["email"];?>" /></td>
	<td align="center"><input type="text" name="txtEditpersonal_type" size="8" value="<?php echo $objResult["personal_type"];?>" /></td>
    <td align="center"><input type="text" name="txtEditaffiliation" size="8" value="<?php echo $objResult["affiliation"];?>" /></td>
    <td align="center"><input type="text" name="txtEdituser_log" size="8" value="<?php echo $objResult["user_log"];?>" /></td>
    <td colspan="3" align="right"><div align="center">
    <input type="text" name="txtEditpass_log" size="8" value="<?php echo $objResult["pass_log"];?>" />

    <input name="btnAdd" type="button" id="btnUpdate" value="Update" OnClick="frmMain.hdnCmd.value='Update';frmMain.submit();">
    <!-- <input name="btnAdd" type="button" id="btnCancel" value="Cancel" OnClick="window.location='<?php //echo $_SERVER["PHP_SELF"];?>';"> -->
	<input name="btnAdd" type="button" id="btnCancel" value="Cancel" OnClick="frmMain.hdnCmd.value='Cancel';frmMain.submit();">
    </div></td>
  </tr>
  <?php
	}
  else
	{
  ?>
  <tr>
    <td height="31"><div align="center"><?php echo $objResult["employee_id"];?></div></td>
    <td align="center"><?php echo $objResult["personalgrade"];?></td>
    <td align="center"><?php echo $objResult["title"];?></td>
    <td><div align="center"><?php echo $objResult["f_name"];?></div></td>
    <td align="center"><?php echo $objResult["l_name"];?></td>
    <td align="center"><?php echo $objResult["email"];?></td>
	<td align="center"><?php echo $objResult["personal_type"];?></td>
    <td><div align="center"><?php echo $objResult["affiliation"];?></div></td>
    <td align="center"><?php echo $objResult["user_log"];?></td>
    <td align="center"><?php echo $objResult["pass_log"];?></td>
    <td align="center">


	<a href="<?php echo $_SERVER["PHP_SELF"];?>?page=manage_user&Action=Edit&employee_id=<?php echo $objResult["employee_id"];?>"><img src="images/edit.png" width="20" height="20"  /></a></td>


	<td align="center">
	<a href="JavaScript:if(confirm('Confirm Delete?')==true){window.location='
	<?php echo $_SERVER["PHP_SELF"];?>?page=manage_user&Action=Del&employee_id=<?php echo $objResult["employee_id"];?>';}"><img src="images/delete.png" width="20" height="20"  /></a></td>
  </tr>
  <?php
	}

}
?>

  
</table>

<br>
Total <?php echo $Num_Rows;?> Record : <?php echo $Num_Pages;?> Page :
<?php
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?page=manage_user&Page=$Prev_Page'><< Back</a> ";
}
 
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?page=manage_user&Page=$i'>$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?page=manage_user&Page=$Next_Page'>Next>></a> ";
}
?>


</form>
</body>
</html>




Tag : PHP, MySQL









ประวัติการแก้ไข
2012-05-15 00:31:38
Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2012-05-15 00:29:42 By : phongphisut View : 825 Reply : 3
 

 

No. 1



โพสกระทู้ ( 113 )
บทความ ( 0 )



สถานะออฟไลน์


บรรทัดที่ 166 อะครับเหมือนกับว่าเวลาเรากดแล้วมันต้องเรียกหน้านี้อะครับ

แก้หน้าแรกได้
Code (PHP)
http://localhost/ecit/admin_regis.php?page=manage_user&Page=1&Action=Edit&employee_id=999999


แก้หน้าสองได้
Code (PHP)
http://localhost/ecit/admin_regis.php?page=manage_user&Page=2&Action=Edit&employee_id=888888


แต่ผมไม่รู้จะกำหนดตรงนี้ยังไงอะครับ

Code (PHP)
&Page=2&







แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-05-15 00:34:09 By : phongphisut
 


 

No. 2



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ส่วค่า page ไปด้วยครับ เช่น

Code
page=<?=$_GET["page"];?>&Page=<?=$_GET["Page"];?>

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-05-15 06:27:12 By : mr.win
 

 

No. 3



โพสกระทู้ ( 113 )
บทความ ( 0 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 2 เขียนโดย : mr.win เมื่อวันที่ 2012-05-15 06:27:12
รายละเอียดของการตอบ ::
ขอบคุณครับพี่วิน

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-05-15 08:34:25 By : phongphisut
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : รบกวนดู code ให้หน่อยครับทำหน้า แก้ไข กับ ลบในหน้าเดิม
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 03
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่