简体   繁体   English

选择表中特定行的ID

[英]Select the id of a specific row in a table

I have a list of data: 我有一个数据列表:

id  |  username  |  name  | product  | date  

Now, I have a varying amount of rows. 现在,我有不同数量的行。

Eg: 例如:

1  |  bob123  |  John Doe  |  1/1/2000


3  |  steven30  |  John Bradley Doe  |  3/5/1998

etc.... 等等....

Now, I have a button attached to each row. 现在,我在每行上都有一个按钮。 When the button is clicked, I want to be able to detect the id of that row. 单击按钮后,我希望能够检测到该行的id For example, I press the button on bob123 's row. 例如,我按bob123的行上的按钮。 I want the PHP to echo the id of that row, which is one. 我希望PHP回显该行的ID,即这一行。 Is there any way to do this? 有什么办法吗?

$idSelect = mysql_query("SELECT id FROM data WHERE id='<detect id here>'");

HTML file HTML文件

<a href="file.php?id=1" role="button" rel="nofollow">BOOB1234</a>

PHP 的PHP

if (isset($_GET['id']) && (INT)$_GET['id']) {
 echo 'ID is: ' . $_GET['id'];
exit;
}

Of curse you might need to do more stuff in the php... I have no idea how you want it, but you can try that... 的诅咒,您可能需要在php中做更多的事情。。。我不知道您想要什么,但是您可以尝试一下。

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

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