|
|
|
รบกวนสอบถามเรื่อง Update ข้อมูลแล้ว แต่ไม่ลงในฐานข้อมูลค่ะ |
|
|
|
|
|
|
|
ลองอัพเดตข้อมูลดูแล้ว แต่มันไม่ลงในฐานข้อมูลค่ะ
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com PHP & MySQL Tutorial</title>
</head>
<body>
<?php
$objConnect = mysql_connect("localhost","root","123456") or die("Error Connect to Database");
$objDB = mysql_select_db("project");
mysql_query("SET character_set_results=utf8");
mysql_query("SET character_set_client=utf8");
mysql_query("SET character_set_connection=utf8");
//*** Update Condition ***//
if($_GET["Action"] == "Save")
{
for($i=1;$i<=$_POST["hdnLine"];$i++)
{
$strSQL = "UPDATE item SET ";
$strSQL .="item_no = '".$_POST["item_no$i"]."' ";
$strSQL .=",item_name = '".$_POST["item_name$i"]."' ";
$strSQL .=",quarter_id = '".$_POST["quarter_id$i"]."' ";
$strSQL .=",item_people = '".$_POST["item_people$i"]."' ";
$strSQL .=",item_use = '".$_POST["item_use$i"]."' ";
$strSQL .=",item_persent = '".$_POST["item_persent$i"]."' ";
$strSQL .=",item_utility = '".$_POST["item_utility$i"]."' ";
$strSQL .=",integration_id = '".$_POST["integration_id$i"]."' ";
$strSQL .=",item_detail = '".$_POST["item_detail$i"]."' ";
$strSQL .="WHERE item_id = '".$_POST["hdnCustomerID$i"]."' ";
$objQuery = mysql_query($strSQL);
}
//header("location:$_SERVER[PHP_SELF]");
//exit();
}
$strSQL = "SELECT * FROM item ORDER BY item_id ASC";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<form name="frmMain" method="post" action="phpMySQLEditRecord2.php?Action=Save">
<input type="hidden" name="hdnCustomerID<?php echo $i;?>" size="5" value="<?php echo $objResult["item_id"];?>">
<table width="600" border="1">
<?php
$i =0;
while($objResult = mysql_fetch_array($objQuery))
{
$i = $i + 1;
?>
<tr>
<td><input type="text" name="item_id<?php echo $i;?>" size="5" value="<?php echo $objResult["item_id"];?>"></td>
<td width="98"><input type="text" name="item_no<?php echo $i;?>" size="20" value="<?php echo $objResult["item_no"];?>"></td>
<td width="198"><input type="text" name="item_name<?php echo $i;?>" size="20" value="<?php echo $objResult["item_name"];?>"></td>
<td width="97"><div align="center">
<select name="txtCountryCode<?php echo $i;?>">
<?php
$strSQL2 = "SELECT * FROM quarter ORDER BY quarter_id ASC";
$objQuery2 = mysql_query($strSQL2) or die ("Error Query [".$strSQL2."]");
while($objResult2 = mysql_fetch_array($objQuery2))
{
if($objResult["quarter_id"] == $objResult2["quarter_id"])
{
$sel = "selected";
}
else
{
$sel = "";
}
?>
<option value="<?php echo $objResult2["quarter_id"];?>" <?php echo $sel;?>><?php echo $objResult2["quarter_name"];?></option>
<?php
}
?>
</select>
</div></td>
<td width="59" align="right"><input type="number" name="item_people<?php echo $i;?>" size="5" value="<?php echo $objResult["item_people"];?>"></td>
<td width="71" align="right"><input type="number" name="item_use<?php echo $i;?>" size="5" value="<?php echo $objResult["item_use"];?>"></td>
<td width="71" align="right"><input type="text" name="item_persent<?php echo $i;?>" size="5" value="<?php echo $objResult["item_persent"];?>"></td>
<td width="71" align="right"><input type="text" name="item_utility <?php echo $i;?>" size="5" value="<?php echo $objResult["item_utility"];?>"></td>
<td width="97"><div align="center">
<select name="txtCountryCode<?php echo $i;?>">
<?php
$strSQL2 = "SELECT * FROM integration ORDER BY integration_id ASC";
$objQuery2 = mysql_query($strSQL2) or die ("Error Query [".$strSQL2."]");
while($objResult2 = mysql_fetch_array($objQuery2))
{
if($objResult["integration_id"] == $objResult2["integration_id"])
{
$sel = "selected";
}
else
{
$sel = "";
}
?>
<option value="<?php echo $objResult2["integration_id"];?>" <?php echo $sel;?>><?php echo $objResult2["integration_name"];?></option>
<?php
}
?>
</select>
</div></td>
<td width="71" align="right"><input type="text" name="item_detail<?php echo $i;?>" size="5" value="<?php echo $objResult["item_detail"];?>"></td>
</tr>
<?php
}
?>
</table>
<input type="submit" name="submit" value="submit">
<input type="hidden" name="hdnLine" value="<?php echo $i;?>">
</form>
<?php
mysql_close($objConnect);
?>
</body>
</html>
Tag : PHP
|
|
|
|
|
|
Date :
2019-03-27 16:35:27 |
By :
error |
View :
617 |
Reply :
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WHERE ไม่มีค่าครับ
|
|
|
|
|
Date :
2019-03-28 09:55:51 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|