我几乎尝试了所有方法,但我无法让这个简单的更新查询工作。
数组显示:
Array ( [pSelect] => 102 [budget] => 44 [submit] => submit )
所以我可以得出结论,它确实获得了 ID 并从输入字段接收值budget
。
<form action="test.php" method="post" action="test.php">
<select name = 'pSelect' id = 'pSelect'>
<?php
$result = mysql_query
("SELECT ID, Project, Projectnummer, Klant, Budget
FROM tblproject
WHERE Status = '1'
ORDER BY Klant ASC
");
while($row1 = mysql_fetch_array($result))
{
$pID = $row1['ID'];
echo "<option value=\"" . $row1['ID'] . "\"";
if (isset($_POST['pSelect']) && $row1['ID'] == $_POST['pSelect'])
{
echo " selected='selected'";
}
echo ">" . $row1['Klant'] ." ". $row1['Project'] ." ". $row1['Projectnummer'] . "</option>";
echo "<br />";
}
?>
</select>
<input type="text" name="budget" />
<?php
if (isset($_POST['submit']))
{
$ID = $_POST['pSelect'];
$budget = $_POST['budget'];
mysql_query
(" UPDATE tblproject SET Budget = '$budget',WHERE ID = '$ID'");
}
print_r($_POST);
?>
<input type="submit" name="submit" value="submit" />
</form>