我成功地在网页上显示来自我的数据库的信息行。我希望能够从表单中编辑该数据。出于某种原因,我的表单链接没有传递数据。
以下是显示数据的相关代码(包括 EDIT 链接):
<table cellspacing="0" cellpadding="5" border="1" width="560">
<tr style="text-align:center">
<td style="text-align:left ; width:175px">Player Name</td>
<td>Team</td>
<td>Pass Yds</td>
<td>Pass TDs</td>
<td>Int Thrown</td>
<td>Rush Yds</td>
<td>Rush TDs</td>
<td></td>
</tr>
<?php
$result = mysql_query("SELECT ID, Player, Team, Pass_Yds, Pass_TDs, Int_Thrown, Rush_Yds, Rush_TDs, Total_Fantasy_Pts FROM ff_projections WHERE Position = 'QB' ORDER BY ID;");
while($row = mysql_fetch_array($result))
{
?>
<tr style="text-align:center">
<td style="text-align:left"><? echo $row['Player']; ?></td>
<td><? echo $row['Team']; ?></td>
<td><? echo $row['Pass_Yds']; ?></td>
<td><? echo $row['Pass_TDs']; ?></td>
<td><? echo $row['Int_Thrown']; ?></td>
<td><? echo $row['Rush_Yds']; ?></td>
<td><? echo $row['Rush_TDs']; ?></td>
<td><a href="edit.php?id=<? echo $row['ID']; ?>">Edit</a></td></tr>
<?php
}
?>
</table>
这是来自edit.php的代码:
<?php
// contact to database
$connect = mysql_connect("localhost", "xxx", "xxx") or die ("Error , check your server connection.");
mysql_select_db("xxx");
$ID=$_GET['ID'];
$result = mysql_query("SELECT * FROM ff_projections WHERE ID = '$ID'") or die ("Error in query");
$row=mysql_fetch_array($result);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form name="edit" method="post" action="confirm.php">
<input name="ID" type="hidden" id="ID" value="<? echo $row['ID']; ?>">
<table width="560" cellspcing="0" cellpadding="5" border="0">
<tr style="text-align:center">
<td style="text-align:left ; width:175px">Player Name</td>
<td>Team</td>
<td>Pass Yds</td>
<td>Pass TDs</td>
<td>Int Thrown</td>
<td>Rush Yds</td>
<td>Rush TDs</td>
<td></td>
</tr>
<tr>
<td><? echo $row['Player']; ?></td>
<td><? echo $row['Team']; ?></td>
<td><input class="edit" name="Pass_Yds" type="text" id="Pass_Yds" value="<? echo $row['Pass_Yds']; ?>"></td>
<td><input class="edit" name="Pass_TDs" type="text" id="Pass_TDs" value="<? echo $row['Pass_TDs']; ?>"></td>
<td><input class="edit" name="Int_Thrown" type="text" id="Int_Thrown" value="<? echo $row['Int_Thrown']; ?>"></td>
<td><input class="edit" name="Rush_Yds" type="text" id="Rush_Yds" value="<? echo $row['Rush_Yds']; ?>"></td>
<td><input class="edit" name="Rush_TDs" type="text" id="Rush_TDs" value="<? echo $row['Rush_TDs']; ?>"></td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>
</body>
</html>
我知道大部分代码已被弃用。一旦我得到这个版本的工作,我将把注意力转向支持代码 - 最有可能使用 mysqli API。
同时,我们将非常感谢您对此提供任何帮助。