|
 |
|
รบกวนช่วยดูโค๊ด select ให้หน่อยครับ มีปัญหาในระบบแก้ไขงานอ่ะครับ |
|
 |
|
|
 |
 |
|
อ่านแล้วมีแต่แก้ไข ๆ ๆ ๆ อ่านแล้วงงครับ
แต่ถ้าพูดถึงการแก้ไข ก็ต้องใช้พวก update ใน code ลองอธิบาย Concept ชัด ๆ หน่อยครับ ช่วยไม่ถูก นึกภาพแก้ไข ๆ ๆ ไม่ออก
|
 |
 |
 |
 |
Date :
2012-08-29 10:40:10 |
By :
apisitp |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อ่อ ขอโทษครับ ผมอธิบายไม่ค่อยจะเก่งอ่ะครับต้องขอโทษด้วย นิคือหน้า ก่อนที่จะ ลิ้งเข้าไปนะครับ

จะเห็นตำแหน่งงานต่างๆ ใช่ไหมครับ แล้วจะมี รูปกระดาษ กับดินสอ พอคลิ๊กตรงนั้นจะทำการแก้ไขงานนั้นๆ เหมือนกับว่า คำสั่งselect ที่ผมโพสก่อนหน้านี้ มันจะเป็นการโชว์ ข้อมูลไว้ใน text box อ่ะครับ คือตอนนี้มันดึง มาแค่ข้อมูลเดียว มันไม่ได้ดึงข้อมูลมาตามที่ต้องการอ่ะครับ
นิคือ select แบบเต็มนะครับ
Code (PHP)
<?
echo $sql5="select * from company_work where work_id = '".$_SESSION['UserID']."'";
$Quser = mysql_query($sql5);
$numrow= mysql_num_rows($Quser);
if($numrow>0){
$Rcom = mysql_fetch_array($Quser);
$work_name = $Rcom["work_name"];
$num_job = $Rcom["num_job"];
$Salary = $Rcom["Salary"];
$Email = $Rcom["Email"];
$sex = $Rcom["sex"];
$age = $Rcom["age"];
$Degree = $Rcom["Degree"];
$prop_job = $Rcom["prop_job"];
}
?>
<center>
<form name="form1" method="post" action="update_job.php">
<input type="hidden" name="wid" id="wid" value= "<? echo $_REQUEST['w_id']?>"/>
<input type="hidden" name="chk" id="chk" value= "edit"/>
<table border="1">
<tr>
<td width="200"><h3> ตำแหน่งที่รับ</h3></td>
<td width="255"><input name="txtjob" type="text" id="txtjob" size="40" value="<? echo $num_job?>">
</td>
</tr>
<tr>
<td><h3> จำนวนที่รับ</h3></td>
<td><h3><input name="txtnum" type="text" id="txtnum" value="<? echo $work_name?>">
อัตรา</h3>
</td>
</tr>
<tr>
<td><h3> ระดับเงินเดือน</h3></td>
<td><h3><input name="txtsalary" type="text" id="txtsalary" size="20" value="<? echo $Salary?>"> บาท</h3>
</td>
</tr>
<tr>
<tr>
<td><h3> เพศ</h3></td>
<td><input name="txtsex" type="text" id="txtsex" size="10" value="<? echo $sex?>">
</td>
</tr>
<tr>
<td><h3> อายุ</h3></td>
<td><h3><input name="txtage" type="text" id="txtage" size="10" value="<? echo $age?>"> ปี</h3>
</td>
</tr>
<tr>
<td><h3> วุฒิการศึกษา</h3></td>
<td><input name="txtdegree" type="text" id="txtdegree" size="40" value="<? echo $Degree?>">
</td>
</tr>
<tr>
<td><h3> สวัสดิการ/คุณสมบัติ</h3></td>
<td><textarea name="txtwel" cols="40" rows="5" id=""><? echo $prop_job?></textarea>
</td>
</tr>
</table>
<br/>
<input type="submit" name="button" value="บันทึก">
</form>
</center>
</td></tr></table>
ในส่วนข้อง update ผมทำได้แล้วครับ แต่เผื่อจะทำให้เข้าใจมากขึ้นนะครับ
Code (PHP)
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?
require("connect.inc_jac.php");
//echo $_REQUEST['chk'];
if($_REQUEST['chk']=="edit"){
$strSQL="update company_work SET work_name='".trim($_POST["txtjob"])."',num_job='".trim($_POST["txtnum"])."',Salary='".trim($_POST["txtsalary"])."',sex='".trim($_POST["txtsex"])."',age='".trim($_POST["txtage"])."',Degree='".trim($_POST["txtdegree"])."',prop_job='".trim($_POST["txtwel"])."' where work_id ='".$_REQUEST['wid']."' ";
$objQuery = mysql_query($strSQL);
echo "<script>alert('แก้ไขข้อมูลเรียบร้อย');window.location.href='look_job.php';</script>";
}
if($_REQUEST['chk']=="delete"){
echo $sql="delete from company_work WHERE work_id='".$_REQUEST['w_id']."'";
$quer=mysql_query($sql);
echo "<script>alert('ลบข้อมูลเรียบร้อย');window.location.href='look_job.php';</script>";
}
mysql_close();
?>
ต้องขอโทษที่อธิบาย ไม่รู้เรื่องนะครับ
|
 |
 |
 |
 |
Date :
2012-08-29 10:56:30 |
By :
jackkieclub |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เท่าที่เห็น userID มันส่งค่ามาค่าเดียวคือ 1 ลองเช็คการส่งค่าดีดีครับ
ตรงรูป รูปกระดาษ กับดินสอ ดู code ส่งค่าที่อ้าง id ให้ถูกต้องครับ
|
 |
 |
 |
 |
Date :
2012-08-29 11:17:02 |
By :
apisitp |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
</td>
<td align="center" style="padding:10px"><a href="edit_job.php?w_id=<? echo $recQuery['work_id'];?>"><img src="image/edit.jpg" border="0"></a> <a href="update_job.php?w_id=<? echo $recQuery['work_id'];?>&chk=delete"><img src="image/delete.jpg" border="0"></a></td
โค๊ดตรงรูปมันเป็นแบบนี้อ่ะครับ คือมันจะต้อง
ตรวจเช็คยังไง อ่ะครับ
|
 |
 |
 |
 |
Date :
2012-08-29 11:26:29 |
By :
jackkieclub |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|