简体   繁体   English

如何从表中选择行?

[英]How to select row from table?

I have created a table that displays the results from a MYSQL database. 我创建了一个表,该表显示来自MYSQL数据库的结果。 At the end of each row, I have added a button that when clicked on inserts the session username into the database. 在每一行的末尾,我添加了一个按钮,单击该按钮会将会话用户名插入数据库。 Apart from the session username I want to insert all the other details present in the table ROW in which the button is present. 除了会话用户名外,我想在存在按钮的表ROW中插入所有其他详细信息。

How do I do that? 我怎么做?

I presume you have some sort of form for each row to hold your submit button? 我想您每行都有某种形式的表格来保存您的提交按钮?

If thats the case you can use hidden field form elements. 如果是这样,您可以使用隐藏字段表单元素。 in each cell of the row add an hidden field and set the values. 在该行的每个单元格中,添加一个隐藏字段并设置值。 upon when the user submits that info is passed to via POST or GET. 当用户提交该信息时,将通过POST或GET传递给该信息。 Be warned that doing this means the user could tamper with the data before submitting entering invalid info. 请注意,这样做意味着用户可以在提交输入无效信息之前篡改数据。

To avoid the above issue you can just pass the ID of the row to the form and on submit read the id, get the result for the DB and then insert into into another table or database. 为避免上述问题,您可以将行的ID传递给表单,并在提交时读取ID,获取DB的结果,然后将其插入到另一个表或数据库中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM