任何人都可以帮助解决这个问题。当我尝试使用catid更新多个记录时(它包含一个或多个相同的catid),它不会更新结果。
以下是代码
在这里输入代码
<?php
//select a database to work with
$selected = mysql_select_db("db_name",$cnn) or die("Could not select examples");
$sql="SELECT *
FROM `plannedbudgetstbl`
LEFT JOIN budget_categories ON plannedbudgetstbl.cat_id = budget_categories.cat_id
WHERE programid ='".$id."'";
$result=mysql_query($sql);
// Count table rows
$count=mysql_num_rows($result);
?>
<form name="form1" method="post" action="">
<table width="500" border="0" cellspacing="1" cellpadding="0">
<tr>
<td>
<table width="500" border="0" cellspacing="1" cellpadding="0">
<tr>
<td align="center"><strong>budget</strong></td>
</tr>
<?php
// Check if button name "submit" is active, do this
if (isset($_POST['submit'])) {
$budget = $_POST['budget'];
for($i=0;$i<$count;$i++){
$sql1="UPDATE plannedbudgetstbl SET budget='".$budget[$i]."' WHERE programid = '".$id[$![enter image description here][1]i]."'and cat_id='".$id[$i]."'";
$result1=mysql_query($sql1);
}
}
if(isset($result1)){
header("location:budget-dispaly1.php");
}
?>
<?php
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td align="center"><?php $id[]=$rows['cat_id']; ?><?php echo $rows['cat_id']; ?></td>
<td align="center"><input name="budget[]" type="text" id="budget" value="<?php echo $rows['budget']; ?>"></td>
</tr>
<?php
}
?>
<tr>
<td colspan="4" align="center"><input type="submit" name="submit" value="submit"></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
这是更新输出