Jump to content

Using a link to change page content


dankine

Recommended Posts

Well phrased topic I know.

 

Basically I have a page to enter data into a mysql db via a form. After the data has been input, this form disappears and instead (on the same page) the data is shown in the same format, just not editable anymore.

 

What I need to do is have a link that will be able to switch between the two states, being 'edit' and 'view'.

 

Can anyone help point me in the right direction?

It would be very much appreciated.

Link to comment
https://forums.phpfreaks.com/topic/71678-using-a-link-to-change-page-content/
Share on other sites

<?php

  if (isset($_GET['action'])) {
    $action = 'view'; // default.
  } else {
    $action = $_GET['action'];
  }

  if ($action == 'view')) {
    // display data
    echo "<a href='?action=edit'>edit</a>";
  } else {
    // display form
    echo "<a href='?action=view'>view</a>";
  }

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.