Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7513705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:16:04+00:00 2026-05-30T00:16:04+00:00

I was wondering if anyone could help me with this problem i’m having. I

  • 0

I was wondering if anyone could help me with this problem i’m having.
I have a ReminderDAO class with methods to delete, edit, insert etc and a Reminder class with a constructor and get and sets.

I then have a a view reminders where it just lists all the reminders out.
I want to be able to add an edit and delete to this view page.

To use the delete and edit functions in my ReminderDAO class, i need to pass a reminder object through the function and i’m not quite sure how to do this.

If anyone could help me that would be of great help, i’m new to this language so i apologise if it’s not great code.

Thank you in advance!

Reminder DAO

class ReminderDAO extends DAO {

    public function __construct() {
        parent::__construct();
    }

    public function insert($reminder) {
        if (!isset($reminder)) {
            throw new Exception("Reminder required");
        }
        $sql = "INSERT INTO Reminders(member_id, title, details, reminder_type) VALUES (?, ?, ?, ?)";
        $params = array($reminder->getMember_id(), $reminder->getTitle(), $reminder->getDetails(), $reminder->getType());
        $stmt = $this->link->prepare($sql);
        $status = $stmt->execute($params);
        if ($status != true) {
            $errorInfo = $stmt->errorInfo();
            throw new Exception("Could not save Reminder: " . $errorInfo[2]);
        }

        $sql = "SELECT LAST_INSERT_ID()";
        $stmt = $this->link->prepare($sql);
        $status = $stmt->execute();
        if ($status != true) {
            $errorInfo = $stmt->errorInfo();
            throw new Exception("Could not retrieve new reminder's id: " . $errorInfo[2]);
        }
        $row = $stmt->fetch();
        $id = $row[0];
        $reminder->setId($id);
    }

    public function delete($reminder) {
        if (!isset($reminder)) {
            throw new Exception("Reminder required");
        }
        $id = $reminder->getId();
        if ($id == null) {
            throw new Exception("Reminder id required");
        }
        $sql = "DELETE FROM Reminders WHERE id = ?";
        $params = array($reminder->getId());
        $stmt = $this->link->prepare($sql);
        $status = $stmt->execute($params);
        if ($status != true) {
            $errorInfo = $stmt->errorInfo();
            throw new Exception("Could not delete reminder: " . $errorInfo[2]);
        }
    }

    public function update($reminder) {
        if (!isset($reminder)) {
            throw new Exception("Reminder required");
        }
        $id = $reminder->getId();
        if ($id == null) {
            throw new Exception("Reminder id required");
        }
        $sql = "UPDATE Reminders SET member_id = ?, title = ?, details = ?, reminder_type = ? WHERE id = ?";
        $params = array($reminder->getMember_id(), $reminder->getTitle(), $reminder->getDetails(), $reminder->getType());
        $stmt = $this->link->prepare($sql);
        $status = $stmt->execute($params);
        if ($status != true) {
            $errorInfo = $stmt->errorInfo();
            throw new Exception("Could not update Reminder: " . $errorInfo[2]);
        }
    }

    public function getReminder($id) {
        $sql = "SELECT * FROM Reminders WHERE id = ?";
        $params = array($id);
        $stmt = $this->link->prepare($sql);
        $status = $stmt->execute($params);
        if ($status != true) {
            $errorInfo = $stmt->errorInfo();
            throw new Exception("Could not retrieve Reminder: " . $errorInfo[2]);
        }

        $reminder = null;
        if ($stmt->rowCount == 1) {
            $row = $stmt->fetch();
            $id = $row['id'];
            $member_id = $row['member_id'];
            $title = $row['title'];
            $details = $row['details'];
            $type = $row['reminder_type'];
            $reminder = new ReminderDAO($id, $member_id, $title, $details, $type);
        }
        return $reminder;
    }

    public function getReminders() {
        $sql = "SELECT * FROM  Reminders";
        $stmt = $this->link->prepare($sql);
        $status = $stmt->execute();
        if ($status != true) {
            $errorInfo = $stmt->errorInfo();
            throw new Exception("Could not retrieve reminders: " . $errorInfo[2]);
        }

        $reminders = array();
        $row = $stmt->fetch();
        while ($row != null) {
            $id = $row['id'];
            $member_id = $row['member_id'];
            $title = $row['title'];
            $details = $row['details'];
            $type = $row['reminder_type'];


            $reminder = new Reminder($id, $member_id, $title, $details,  $type);
            $reminders[$id] = $reminder;

            $row = $stmt->fetch();
        }
        return $reminders;
    }
}
?>

Reminder Class

<?php
class Reminder {
    private $id;
    private $member_id;
    private $title;
    private $details;
    private $reminder_type;


    public function __construct($i, $m_id, $title, $det, $type) {
        $this->id = $i;
        $this->member_id = $m_id;
        $this->title = $title;
        $this->details = $det;
        $this->reminder_type = $type;
    }
    public function getId() { return $this->id; }
    public function getMember_id() { return $this->member_id; }
    public function getTitle() { return $this->title; }
    public function getDetails() { return $this->details; }
    public function getType() { return $this->reminder_type; }


    public function setId($i) { $this->id = $i; }
    public function setMember_id($mID) { $this->member_id = $mID; }
    public function setTitle($t) { $this->title = $t; }
    public function setDetails($d) { $this->details = $d; }
    public function setType($type) { $this->reminder_type = $type; }


}
?>

View Reminders

<?php
ob_start();
require_once 'includes/Member.php';
require_once 'includes/MemberDAO.php';
require_once 'includes/Reminder.php';
require_once 'includes/ReminderDAO.php';
require_once 'includes/session.php';
confirm_logged_in(); // needs to come before any html because it does a redirect
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
        <?php
        require 'toolbar.php';
        $member = ($_SESSION['member']);

        $reminderDAO = new ReminderDAO();
        $reminders = $reminderDAO->getReminders();



        echo "<p>Hello " . $member->getFN() . "</p>";
        echo "<p>These are the current reminders:  </p>";


        foreach ($reminders as $rem) {
            echo "<b>Title:</b> " . $rem->getTitle() . "<br />";
            echo "<b>Details:</b> " . $rem->getDetails() . "<br />";
            echo "<b>Type: </b>" . $rem->getType() . "<br />";



           echo "</p>";

        }


        echo $display; ?>
        <a href="add_reminder_form.php">Add Reminder?</a>



    </body>
</html>
<?php ob_flush(); ?>

edit_reminder_form.php class

<?php
ob_start();
require_once 'includes/session.php';
require_once 'includes/Member.php';
require_once 'includes/MemberDAO.php';
require_once 'includes/Reminder.php';
require_once 'includes/ReminderDAO.php';
require_once 'includes/session.php';
confirm_logged_in(); // needs to come before any html because it does a redirect
?>

<?php

 $reminderDAO = new ReminderDAO();
 $reminder = $reminderDAO->getReminder($_GET['id']);




?>

<html>
    <head>
        <title>Edit Reminder</title>
    </head>
    <body>

        <table>
            <tr>
            <td>
            <h2>Edit Reminder</h2>
             <?php if (isset($_GET['errorMessage'])) echo "<p>".$_GET['errorMessage']."</p>"; ?>
               <form action="edit_reminder.php" method="POST">
                   Title: <input type="text" name="title" value="<?php $reminder->getTitle(); ?>" /><br/>
                   Details: <input type="text" name="details" value="<?php $reminder->getDetails()?> " /><br/>

                   <select name="reminder_type" value="<?php $reminder->getType();?>">
                <option value="Choose">Please choose a reminder type!</option>
                <option value="Bill">Bill</option>
                <option value="Shopping">Shopping</option>
                <option value="Event">Event</option>
                <option value="Birthday">Birthday</option>
                <option value="Other">Other</option>
                </select>
                <br />
                <input type="submit" name="reminder" value="Edit Reminder" />
               </form>
            <br />
            <a href ="view_reminders.php"> Cancel </a>
            </td>
            </tr>
        </table>
    </body>
    <?php
    //5.Close connection
    if(isset($connection)) {
     mysql_close($connection);
    }
    ?>
</html>

<?php ob_flush(); ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T00:16:06+00:00Added an answer on May 30, 2026 at 12:16 am

    You could send the ID of the reminder to the next page where you edit/delete a reminder.

    foreach ($reminders as $rem) {
            echo "<b>Title:</b> " . $rem->getTitle() . "<br />";
            echo "<b>Details:</b> " . $rem->getDetails() . "<br />";
            echo "<b>Type: </b>" . $rem->getType() . "<br />";
    
            echo "[<a href='edit.php?id=" . $rem->getID() . "'>Edit</a>] ";
            echo "[<a href='delete.php?id=" . $rem->getID() . "'>Delete</a>] ";
    
           echo "</p>";
    
        }
    

    In edit.php you get the reminder object using the ID (e.g. $_GET['id']), load the data from the database using ReminderDAO and create a form populated with the reminder values. In that form, you should also put the reminder id, so when he submit the form to Save changes, you can identify the reminder that was edited.
    After saving the changes, you can redirect him back to the list of reminders using header function.

    Similar, in delete.php you can delete the reminder using the ID (e.g. $_GET['id']) and then redirect the user to the list of reminders.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering if anyone could help me with this problem: I have to
I am stuck on this problem and was wondering if anyone could help me
I was wondering if anyone could help me with this minor problem. I want
I was wondering if anyone could help clear up this issue I am having.
Just wondering if anyone could help me with this. I'm new to actionscript, and
I was wondering if anyone could help me out with this. I am running
Please could anyone help me with this problem? The wordpress admin bar is not
Hey there, was wondering if anyone could help a newbie on SQL and Python.
I was wondering if any one could help me out; I have a table
I was wondering if anyone could point to an Open Source date utility class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.