|
 |
|
รบกวนช่วยดู CODE ให้หน่อยครับ แบบว่ามันไม่ update ลง database |
|
 |
|
|
 |
 |
|
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body,td,th {
color: #000000;
}
-->
</style></head>
<body>
<?
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("ipstar");
//*** Update Condition ***//
if($_GET["Action"] == "Save")
{
for($i=1;$i<=$_POST["hdnLine"];$i++)
{
$strSQL = "UPDATE lineitem SET ";
$strSQL .="SoftwareID = '".$_POST["txtSoftwareID$i"]."' ";
$strSQL .=",DescriptionID = '".$_POST["txtDescriptionID$i"]."' ";
$strSQL .=",TestLocation = '".$_POST["txtTestLocation$i"]."' ";
$strSQL .=",Result = '".$_POST["txtResult$i"]."' ";
$strSQL .=",DetailTab = '".$_POST["txtDetailTab$i"]."' ";
$strSQL .=",UpdateVR = '".$_POST["txtUpdateVersion$i"]."' ";
$strSQL .=",Remark = '".$_POST["txtRemark$i"]."' ";
$strSQL .="WHERE DescriptionID = '".$_POST["hdnDescriptionID$i"]."' AND SoftwareID = '".$_POST["hdnSoftwareID$i"]."'";
$objQuery = mysql_query($strSQL);
}
//header("location:$_SERVER[PHP_SELF]");
//exit();
}
$strSQL = "SELECT * FROM lineitem RIGHT JOIN description ON lineitem.DescriptionID = description.DescriptionID";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<form name="frmMain" method="post" action="testtest.php?Action=Save">
<table width="600" border="1">
<tr>
<th width="100"> <div align="center">SoftwareID </div></th>
<th width="100"> <div align="center">DescriptionID </div></th>
<th width="300"> <div align="center">Description</div></th>
<th width="200"> <div align="center">TestLocation </div></th>
<th width="70"> <div align="center">Result </div></th>
<th width="70"> <div align="center">DetailTab </div></th>
<th width="100"> <div align="center">UpdateVR </div></th>
<th width="300"> <div align="center">Remark </div></th>
</tr>
<?
$i =0;
while($objResult = mysql_fetch_array($objQuery))
{
$i = $i + 1;
?>
<tr>
<td><div align="center">
<input type="hidden" name="hdnDescriptionID<?=$i;?>" size="10" value="<?=$objResult["DescriptionID"];?>">
<input type="hidden" name="hdnSoftwareID<?=$i;?>" size="10" value="<?=$objResult["SoftwareID"];?>">
<input type="text" name="txtSoftwareID<?=$i;?>" size="10" value="<?=$objResult["SoftwareID"];?>">
</div></td>
<td><input type="text" readonly="true" name="txtDescriptionID<?=$i;?>" size="10" value="<?=$objResult["DescriptionID"];?>"></td>
<td><input type="text" readonly="true" name="txtDescription<?=$i;?>" size="50" value="<?=$objResult["Description"];?>"></td>
<td><input type="text" name="txtTestLocation<?=$i;?>" size="15" value="<?=$objResult["TestLocation"];?>"></td>
<td><input type="text" name="txtResult<?=$i;?>" size="10" value="<?=$objResult["Result"];?>"></div></td>
<td><input type="text" name="txtDetailTab<?=$i;?>" size="10" value="<?=$objResult["DetailTab"];?>"></td>
<td><input type="text" name="txtUpdateVersion<?=$i;?>" size="10" value="<?=$objResult["UpdateVR"];?>"></td>
<td><input type="text" name="txtRemark<?=$i;?>" size="50" value="<?=$objResult["Remark"];?>"></td>
</tr>
<?
}
?>
</table>
<input type="submit" name="submit" value="submit">
<input type="hidden" name="hdnLine" value="<?=$i;?>">
</form>
<?
mysql_close($objConnect);
?>
</body>
</body>
</html>
คือผมได้นำ code จาก thaicreate (ที่นี่)ไปประยุกต์ใช้นะครับ แต่ว่ามันไม่ยอม update ลง database ให้ผมนะครับ ยังไงรบกวนผู้รู้ช่วยแนะนำให้หน่อยครับ
Tag : PHP

|
|
 |
 |
 |
 |
Date :
2011-03-25 16:14:20 |
By :
guluzifer |
View :
713 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
$strSQL = "UPDATE lineitem SET ";
$strSQL .="SoftwareID = '".$_POST["txtSoftwareID$i"]."' ";
$strSQL .=",DescriptionID = '".$_POST["txtDescriptionID$i"]."' ";
$strSQL .=",TestLocation = '".$_POST["txtTestLocation$i"]."' ";
$strSQL .=",Result = '".$_POST["txtResult$i"]."' ";
$strSQL .=",DetailTab = '".$_POST["txtDetailTab$i"]."' ";
$strSQL .=",UpdateVR = '".$_POST["txtUpdateVersion$i"]."' ";
$strSQL .=",Remark = '".$_POST["txtRemark$i"]."' ";
$strSQL .="WHERE DescriptionID = '".$_POST["hdnDescriptionID$i"]."' AND SoftwareID = '".$_POST["hdnSoftwareID$i"]."'";
ตรงนี้ให้เปลี่ยนเป็นแบบนี้
$strSQL = "UPDATE lineitem SET SoftwareID = '".$_POST["txtSoftwareID$i"]."' ,DescriptionID = '".$_POST["txtDescriptionID$i"]."' ,TestLocation = '".$_POST["txtTestLocation$i"]."',Result = '".$_POST["txtResult$i"]."' , DetailTab = '".$_POST["txtDetailTab$i"]."' ,UpdateVR = '".$_POST["txtUpdateVersion$i"]."' , Remark = '".$_POST["txtRemark$i"]."' WHERE DescriptionID = '".$_POST["hdnDescriptionID$i"]."' AND SoftwareID = '".$_POST["hdnSoftwareID$i"]."' ";
คุณต้องเขียนแบบนี้นะคับ
มีไร้ไม่เข้าใจสอบถามได้นับคับ
[email protected]
|
 |
 |
 |
 |
Date :
2011-03-25 16:43:48 |
By :
j_job_php |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|