+-----+-------+--------+
ID | Owner | Number |
+-----+-------+--------+
com1 | peter | 103045 |
+-----+-------+--------+
com2 | deter | 103864 |
+-----+-------+--------+
大家好。我正在处理项目的这一部分,假设用户输入某个 ID。当他输入这个特定的 ID 时,假设打印出该 ID 行中的所有内容。在这种情况下,如果他输入 com1,它将显示:
+-----+-------+--------+
ID | Owner | Number |
+-----+-------+--------+
com1 | peter | 103045 |
+-----+-------+--------+
我使用了这个表格和代码:
表单.php
<form action="query.php" method="POST">
Enter your ID: <input type="varchar" name="id" /><br />
<input type="submit" value="Audit" />
</form>
查询.php
$con = mysql_connect("localhost", "root", "");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("livemigrationauditingdb", $con);
$input = (int) $_POST['id'];
$query = mysql_query("SELECT * FROM system_audit WHERE ID = $input");
echo "<table border='1'>
<tr>
<th>ID</th>
<th>Owner</th>
<th>Number</th>
</tr>";
while($row = mysql_fetch_array($query))
{
echo "<tr>";
echo "<td>" . $row['ID'] . "</td>";
echo "<td>" . $row['Owner'] . "</td>";
echo "<td>" . $row['Number'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
认为你们知道错误吗?哦,我是否可以不将其链接到其他页面?我需要将表格和代码放在一页中。目前我的表单链接到 query.php。有没有办法取消这条线,它仍然有效。谢谢!