gpt4 book ai didi

PHP 表列

转载 作者:太空宇宙 更新时间:2023-11-04 10:47:58 25 4
gpt4 key购买 nike

所以我的 PHP 显示了一个 MySQL 表,我知道你可以按我的计划对这些进行分类。但如下图所示,添加按钮添加了另一列。 enter image description here

是否可以使两列下方的添加按钮更新和删除?如果可以,我该怎么做。这是我的代码,对于任何错误或困惑,我深表歉意,我还在学习。

while ($record = mysql_fetch_array($myData)) {
echo "<form action=usermanagement.php method=post>";
echo "<tr>";
echo "<td>" . "<input type=text name=id value=" . $record['ID'] . " </td>";
echo "<td>" . "<input type=text name=rank value=" . $record['Rank'] . " </td>";
echo "<td>" . "<input type=text name=username value=" . $record['Username'] . " </td>";
echo "<td>" . "<input type=text name=password value=" . $record['Password'] . " </td>";
echo "<td>" . "<input type=hidden name=hidden value=" . $record['ID'] . " </td>";
echo "<td>" . "<input type=submit name=update value=update" . " </td>";
echo "<td>" . "<input type=submit name=delete value=delete" . " </td>";
echo "</tr>";
echo "</form>";
}
echo "<form action=usermanagement.php method=post>";
echo "<tr>";
echo "<td><input type=text name=uid></td>";
echo "<td><input type=text name=urank></td>";
echo "<td><input type=text name=uusername></td>";
echo "<td><input type=text name=upassword></td>";
echo "<td>" . "<input type=submit name=add value=add" . " </td>";
echo "</form>";
echo "</table>";

最佳答案

注意输入的结束标记。隐藏的输入可以放在表格中的任何位置,因为它们不会显示:

while($record = mysql_fetch_array($myData)) {
echo '<form action=usermanagement.php method=post>
<tr>
<td>
<input type=text name=id value="' . $record['ID'] . '" />
</td>
<td>
<input type=text name=rank value="' . $record['Rank'] . '" />
</td>
<td>
<input type=text name=username value="' . $record['Username'] . '" />
</td>
<td>
<input type=text name=password value="' . $record['Password'] . '" />
</td>
<td>
<input type=hidden name=hidden value="' . $record['ID'] . '" />
<input type=submit name=update value=update />
</td>
<td>
<input type=submit name=delete value=delete />
</td>
</tr>
</form>';
}

echo '<form action=usermanagement.php method=post>
<tr>
<td>
<input type=text name=uid />
</td>
<td>
<input type=text name=urank />
</td>
<td>
<input type=text name=uusername />
</td>
<td>
<input type=text name=upassword />
</td>
<td colspan="2">
<input type=submit name=add value=add />
</td>
</tr>
</form>';

此外,尝试停止使用 mysql_* 函数,因为它们已被弃用。请改用 PDOmysqli_MySQLi 类。

关于PHP 表列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35226730/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com