Select a row to delete/modify

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Franco Fellico'

    Select a row to delete/modify

    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
  • Pedro Graca

    #2
    Re: Select a row to delete/modify

    Franco Fellico' wrote:[color=blue]
    > 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.[/color]

    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.ph p?id=', $record['id'], '">delete</a> / ';
    echo '<a href="modify.ph p?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

    Comment

    Working...