先生,
我的表格里有两个文本框。
我的数据是。。。
列1价格
501 1
502 2
503 3
504 1
505 2
506 3
507 1
像智者一样。。。
我需要从输入的文本框值更新价格列的所有值
用于文本框中的Ex输入值,如
monthtextbox=1
价格文本框=50,然后
在价格列中用50更新所有1
下面是我的代码,但这并没有更新任何值。plz建议我使用update语句。
<?php
$errors = array();
if(isset($_POST['update']))
{
$month = $_POST['month'];
$price = $_POST['price'];
$modified = date("Y-m-d H:i:s");
$updaterow = $database->updateRow("UPDATE scheme_master SET price = :price WHERE price = :price",
array(':price'=>$price,':price'=>$month,':modified'=>$modified));
$_SESSION['message'] = "Data Updated Successfully";
}
?>
<form name="frm2" method="post" action="">
<div id="page-wrap">
<table height="50">
<tr>
<td width="8%">Enter Month :</td>
<td width="19%"><input type="text" name="month" class="" required = "" /></td>
<td width="11%">Enter Price :</td>
<td width="20%"><input type="text" name="price" class="" required = ""/></td>
<td width="12%" height="45"><input type="submit" name="update" value="Save"/></td>
</tr>
</table>
</div>
</form>
在where条件和数组中使用月份更改价格列。这将更新所有值并为您工作。
<?php
$errors = array();
if(isset($_POST['update']))
{
$month = $_POST['month'];
$price = $_POST['price'];
$updaterow = $database->updateRow("UPDATE scheme_master SET price = :price WHERE price = :month",
array(':price'=>$price,':month'=>$month));
$_SESSION['message'] = "Data Updated Successfully";
}
?>