Rob
Rob

Reputation: 1539

Displaying data on row of submit button

Basically I have a table that is being used to display data from an sql table.

Each row in the database is looped through so each row in the database is also displayed on a new row in the html table.

I have a submit button included in the loop which is displayed in the last column of each row.

What I want is when one of the submit buttons are pressed, the data on that specific row is stored and the displayed on the next page which is the forms action.

I'm not sure if this is possible the way I have done it or if I need a unique identifier for each submit button.

Any help would be appreciated :)

Upvotes: 0

Views: 2140

Answers (1)

JimmyBanks
JimmyBanks

Reputation: 4728

well each row in the sql should have a unique identifier, use this identifier to distinguish which row of the html table that the user selected.

simply, on the submit button have a post or get value of that unique identifier.

When the next page is loaded, use $_GET or $_POST to recieve that unique identifier, use SQL to find the data of that row, and then display it to the html at the top of the new page.

I believe that is what you are asking. Since you didnt ask for specific code.

EDIT: If you want to use a get, use a simple anchor: just have the id in the url

<a href="tablepage.php?rowid=$rowid">Submit</a>

on the new page that links to, you just use

$id=intval($_GET['rowid']) //the intval is for verification security

or if you want to use a post, use a form

<form name="table" action="/tablepage.php" method="post">
<input type="submit" value="Submit" /> //this is the submit button, use a div to change its look
<input type="hidden" name="post" value="$rowid" />   //this contains the unique id in the post
</form>

and on the next page you get the post value through

  $id=intval($_POST['rowid'])       

Upvotes: 1

Related Questions