|
|
|
จะแก้ไข List Box แต่อยากให้แสดงข้อมูลเดิมไว้ตอนแรก.... |
|
|
|
|
|
|
|
ขอโค๊ดด้วยคับ
|
|
|
|
|
Date :
2014-06-11 11:19:27 |
By :
โจจิงหรือ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?
//*** Update Condition ***//
if($_POST["hdnCmd"] == "Update")
{
$strSQL = "UPDATE tbpa1 SET ";
//$strSQL .="emp_id = '0' " ;
$strSQL .="pa1_detail = '".$_POST["txtdetail"]."' ";
$strSQL .=",pa1_status = '".$_POST["status2"]."' ";
/*$strSQL .=",Email = '".$_POST["txtEditEmail"]."' ";
$strSQL .=",CountryCode = '".$_POST["txtEditCountryCode"]."' ";
$strSQL .=",Budget = '".$_POST["txtEditBudget"]."' ";
$strSQL .=",Used = '".$_POST["txtEditUsed"]."' ";*/
$strSQL .="WHERE pa1_id = '".$_POST["id"]."' ";
$objQuery = mysql_query($strSQL);
if(!$objQuery)
{
echo "Error Update [".mysql_error()."]";
}
//header("location:$_SERVER[PHP_SELF]");
//exit();
}
$strSQL = "SELECT * FROM tbpa1 order by pa1_id asc";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<center>
<form name="frmMain" method="post" action="<?=$_SERVER["PHP_SELF"];?>">
<input type="hidden" name="hdnCmd" value="">
<table width="700" border="1">
<tr>
<th width="5%"> <div align="center">ลำดับ</div></th>
<th width="75%"> <div align="center">หน้าที่ความรับผิดชอบ</div></th>
<th width="10%"> <div align="center">วิเคราะห์ </div></th>
<th width="5%"> <div align="center">** </div></th>
<th width="5%"> <div align="center">**</div></th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{ $i = 1;
?>
<?
if($objResult["pa1_id"] == $_GET["CusID"] and $_GET["Action"] == "Edit")
{
?>
<tr>
<td><?=$i;?></td>
<td><input type="text" name="txtdetail2" id="txtdetail2" size="20" value="<?=$objResult["pa1_detail"];?>"></td>
<td> <select name="status2" id = "status2">
<option value="1">✓</option>
<option value="2">O</option>
<option value="3">✕</option>
</select>
</td>
<input type="hidden" name="id" id="idd" value="<?=$objResult["pa1_id"];?>"></td>
<td colspan="2" align="right"><div align="center">
<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='<?=$_SERVER["PHP_SELF"];?>';">
</div></td>
</tr>
<?
}
else
{
?>
<tr>
<td><center><?=$i;?></center></td>
<td><?=$objResult["pa1_detail"];?></td>
<td>
<? if($objResult["pa1_status"]== '1'){echo"✓";}
else if($objResult["pa1_status"]== '2'){echo"O";}
else if($objResult["pa1_status"]== '3'){echo"✕";}
?>
</td>
<td align="center"><a href="<?=$_SERVER["PHP_SELF"];?>?Action=Edit&CusID=<?=$objResult["pa1_id"];?>">Edit</a></td>
<td align="center"><a href="JavaScript:if(confirm('Confirm Delete?')==true){window.location='<?=$_SERVER["PHP_SELF"];?>?Action=Del&CusID=<?=$objResult["pa1_id"];?>';}">Delete</a></td>
</tr>
<?
}
?>
<?
$i++ ; }
?>
<tr>
<td></td>
<td><input type="text" name="txtdetail" size="100"></td>
<td> <select name="status" id = "status" >
<option value="1">✓</option>
<option value="2">O</option>
<option value="3">✕</option>
</select>
</td>
<!--<td><input type="text" name="txtAddEmail" size="20"></td>-->
<td colspan="2" align="right"><div align="center">
<input name="btnAdd" type="button" id="btnAdd" value="Add" OnClick="frmMain.hdnCmd.value='Add';frmMain.submit();">
</div></td>
</tr>
</table>
</form>
<?
mysql_close($conn);
?>
ประมาณนี้ครับ
|
|
|
|
|
Date :
2014-06-11 11:28:08 |
By :
pungpoo |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตรง list ลองเปลี่ยนโค้ดนี้ดูครับ
<select name="status" id="status">
<option value="1" <? if($objResult["pa1_status"])
{echo 'selected="true"';}?>>✓</option>
<option value="2" <? if($objResult["pa1_status"])
{echo 'selected="true"';}?>>O</option>
<option value="3" <? if($objResult["pa1_status"])
{echo 'selected="true"';}?>>✕</option>
</select>
|
ประวัติการแก้ไข 2014-06-11 11:39:57 2014-06-11 11:41:43 2014-06-11 11:47:42 2014-06-11 11:48:07
|
|
|
|
Date :
2014-06-11 11:38:24 |
By :
jpong7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Unidentifier ผมดูไม่ละเอียด ผิดพลาดเลยครับ ขอโทษด้วย อิอิ
|
|
|
|
|
Date :
2014-06-11 11:49:34 |
By :
jpong7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ได้แล้วครับ ขอบคุณทุกคนครับ
|
|
|
|
|
Date :
2014-06-11 11:49:40 |
By :
pungpoo |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|