By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,396 Members | 2,501 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,396 IT Pros & Developers. It's quick & easy.

Select a row to delete/modify

P: n/a
Hi.

Suppose to have read and displayed (using PHP) a group of row of a DB
table on a dinamyc table on a HTML/PHP page.

The number of row displayed could be from 1 to n. Each row contains
informations and also a cell with a unique ID of the element.

I would like to show at the beginning of each line of the table a
couple of cells containing two different icons (one for delete and one
for modify) so the user could click on it to delete/modify the
corresponding row on the DB table.

In other word I need to delete/modify the Dbtable row which have the
ID of the line where the icon was clicked. This means also that when a
icon is clicked I must jump to a PHP routine passing it the ID that
appears on the same line of the icon clicked.

I have seen a similar method of delete/modify on the phpAdmin program,
but I was unable to understand how it work because of the complexity
of that routines.

To achieve my need I can use, if necessary, also Javascript
statements.
Thank you from Franco in Italy
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Franco Fellico' wrote:
I would like to show at the beginning of each line of the table a
couple of cells containing two different icons (one for delete and one
for modify) so the user could click on it to delete/modify the
corresponding row on the DB table.

In other word I need to delete/modify the Dbtable row which have the
ID of the line where the icon was clicked. This means also that when a
icon is clicked I must jump to a PHP routine passing it the ID that
appears on the same line of the icon clicked.


Include the record id in the link associated with the delete/modify
icon, for example:

<?php
// ...
// data from db is in the array $dbdata
foreach ($dbdata as $record) {
echo '<a href="delete.php?id=', $record['id'], '">delete</a> / ';
echo '<a href="modify.php?id=', $record['id'], '">modify</a>';
echo ' | ', $record['name'], ' | ', $record['eyecolor'], ' | '; // ...
// ...
}
?>
to generate HTML that looks like

_delete_ / _modify_ | Franco Fellico | brown | ...
_delete_ / _modify_ | Pedro Graca | brown | ...
...
and in delete.php and modify.php
check for $_GET['id'] and use it (after validating) for
deleting/modifying the record.
HTH

--
..sig
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.