treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Deleting a page with PHP[CMS]

  • Hi
    I have this CMS I've been working on, and I want the user to be able to edit and remove the pages within the site.
    I have it so it's listing all the pages within the site, and I have a link to the right which gives the user the option to f.e. remove the page completely.

    Here's a screen of it, might give you a better idea:
    See here

    The problem I have is I am not sure how to connect the link to each page, does anyone have a good solution for this?

    (I have it so I am listing the ID of each page to the right as well. Just not visible.)

    Thank you!
  • What I mean is, how should I connect the link that is clicked to my delete_page_parse.php
  • I assume pages have an ID. Why not use that as part of a GET request attached to the link.

    Pseudocode:

    <?php
    foreach ( $pages as $page ) {
    ?>
    <tr>
    <td><?php echo $page->page-name; ?></td>
    <td><?php echo $page->last-modified; ?></td>
    <td><a href="delete_page_parse.php?id=<?php echo $page->page-id; ?>">Delete page</a></td>
    </tr>
    <?php
    }
    ?>
  • I got my hands on another solution which worked :)

    Thank you!