JLearner
JLearner

Reputation: 1311

Retrieving sqlite table values

Just a knowledge question which I would like to ask:

For example, I have a table retrieved from sqlite3 database:

ID     Name       Address      Email            Actions
1     Mary       Canada       [email protected]    Modify
2     John       New York     [email protected]    Modify

Upon clicking the actions (Modify) on the specific row like Mary, it will prompt to next webpage to modify the records. So how can I retrieve the table value and bring it to the next web page?

FYI, i'm using sqlite3 and php currently. Please advise if there is any methods to do it.

Thanks

Upvotes: 0

Views: 85

Answers (1)

sk00v
sk00v

Reputation: 206

If I correctly understand your question:

As you are looping through your result set and creating your HTML, you would add your row ID to the modify link, something like:

// Pass $id to the next page
<a href="page-to-modify.php?id=$id">Modify</a>

the $id would be the value from your database, so it would change for each row.

On your "page-to-modify.php" you would then retrieve the $id, for example:

// ID to fetch from the database
$id = intval($_GET['id']);

Then you can select the data again for this ID and populate your edit page.

Hope this helps.

Upvotes: 1

Related Questions