通过PHP隐藏SQL中的索引值
16lz
2021-01-22
I'm currently trying to get users to submit data via PHP/HTML forms and into a SQL database. I can do this happily but would like to not allow users to input the Index
column as it is automatically incrementing ajd wouldn't want to be fiddled with.
我目前正在尝试让用户通过PHP / HTML表单提交数据并进入SQL数据库。我可以愉快地做到这一点,但是不希望用户输入Index列,因为它会自动递增ajd,不希望被摆弄。
The current code I have is like this:
我当前的代码是这样的:
$result = mysql_query("SELECT * FROM {$table}") or die(mysql_error());
// Start a form to run insert.php
echo "<form action=\"insert.php\" method=\"post\">";
// Loop to create boxes in the form
for ($i = 0; $i < $fields_num; $i++)
{
$field = mysql_fetch_field($result);
echo "{$field->name}: <br /><input type=\"text\" name=\"{$field->name}\"onkeypress=\"return noenter()\"/>";
echo "<br />";
};
// End form.
echo "<input type=\"submit\">
</form>
</div>";
From here how could I ignore the Index column. I have total access to the database if that helps.
从这里我怎么能忽略索引列。如果有帮助,我可以完全访问数据库。
Thanks guys, in advance!
谢谢你们,提前!
4 个解决方案
#1
1
If you don't want this field to be displayed, just add a precondition in your loop before generating the output, something like this:
如果您不希望显示此字段,只需在生成输出之前在循环中添加前提条件,如下所示:
for ($i=0; $i<$fields_num; $i++)
{
$field = mysql_fetch_field($result);
if ($field->name != "yourindexfieldname")
{
echo "{$field->name}: <br><input type=\"text\" name=\"{$field->name}\"onkeypress=\"return noenter()\"/>";
echo "<br>";
}
};
更多相关文章
- j2ee的web项目,有最终的html代码(即f12看到的最终给用户浏览器展示
- golang写服务端程序,作为文件上传与下载的服务器。配合HTML5以网
- 维护Java应用程序的多种形式的用户指南
- 我正在尝试使用带有post方法的AJAX将用户名和密码发送到php文件
- HTML5用户身份认证源代码:注册、登录、会话保持的解决方案
- 用于检查用户名可用性的Javascript帖子无效
- 服务器数据库系列 - 日志系列 - Nginx日志
- 在MySQL数据库中搜索与多个Tag记录相关/包含的书签
- 使用jquery和php手动在数据库中增加一个字段[复制]