RATIU5
RATIU5

Reputation: 378

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. For example, I press the button on bob123's row. I want the PHP to echo the id of that row, which is one. Is there any way to do this?

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

Upvotes: 0

Views: 96

Answers (1)

Tanker
Tanker

Reputation: 1196

HTML file

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

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...

Upvotes: 1

Related Questions