這是我的編碼顯示在表用戶的所有數據。該文件的名稱是admindisplay.php我不能更新的第一行表
<?php
//Establish Server Connection String
//Connect to database
include('server.php');
session_start();
//Query database and set result to variable
$result = mysql_query ("SELECT * FROM user");
//Generate Table
echo "<table border='1'><tr><th>No</th><th>Name</th><th>Department</th><th>Date</th><th>Issue</th><th>Details</th><th>Assign Person</th><th>Status</th></tr>";
while($row = mysql_fetch_array($result))
{
$No = $row ['No'];
echo "<tr>";
echo "<td>" . $row['No'] . "</td>";
echo "<td>" . $row['Name'] . "</td>";
echo "<td>" . $row['Department'] . "</td>";
echo "<td>" . $row ['Date'] . "</td>";
echo "<td>" . $row ['Issue'] . "</td>";
echo "<td>" . $row ['Details'] . "</td>";
echo "<td>" . $row ['Assignperson'] . "</td>";
echo "<td>" . $row ['Status'] . "</td>";
echo "<td><form action=\"adminassign.php\" method=\"POST\">
Note: <input type=\"text\" size=\"40\" maxlength=\"100\" name=\"note\">
<label>Assign to:</label>
<select name=\"assign\">
<option value=\"\">-Choose-</option>
<option value=\"Adrian\">Adrian</option>
<option value=\"Trainee\">Trainee</option>
</select>
<input name=\"Nos\" type=\"hidden\" value=\"$No\">
<input name=\"submit\" type=\"submit\" value=\"Assign\"</td>";
}
echo "</table>";
?>
這是我的編碼,我想更新任何行..文件名是adminassign.php
<?php
//Establish Server Connection String
//Connect to database
include('server.php');
session_start();
$No = $_POST ['Nos'];
$Note = $_POST['note'];
$Assign = mysql_real_escape_string(htmlspecialchars($_POST['assign']));
if($Assign=='Adrian')
{
mysql_query("UPDATE user SET Assignperson = 'Adrian' WHERE No = '$No'");
mysql_query("UPDATE user SET Note = '$Note' WHERE No = '$No'");
echo "assign successful";
}
else
{
if($Assign=='Trainee')
{
mysql_query("UPDATE user SET Assignperson = 'Trainee' WHERE No = '$No'");
mysql_query("UPDATE user SET Note = '$Note' WHERE No = '$No'");
echo "assign successful";
}
}
?>
<form action="index.php" method="POST">
<p><input type="submit" value="Log Out">
</form>
<form action="admindisplay.php" method="POST">
<p><input type="submit" value="Back">
</form>
現在的問題是,我只能更新了最後一排..不能更新上一行..任何人都可以幫我解決這個..我已經爲這個唯一的工作了問題已經近一個星期了,我找不到任何解決方案..我是一個新手在這裏..
你從字面上折磨PHP來呼應這麼多的HTML –