- }
-
- private function check_exists() {
- $sql = "SELECT COUNT(*) FROM notes
- WHERE url = ?";
- $results = $this->query($sql, "s", $_GET['note']);
- if ($results[0]["COUNT(*)"] != 1) {
+ $sql = "SELECT title, date_posted, text, id
+ FROM notes WHERE url = ?";
+ $result = $this->query($sql, "s",
+ $_GET['note']);
+ if ($result) {
+ $entry = $result[0];
+ $this->id = $entry["id"];
+ $this->title = $entry["title"];
+ $date_posted = explode("-", $entry["date_posted"]);
+ $this->year_posted = $date_posted[0];
+ $this->month_posted = $date_posted[1];
+ $datetime_posted = explode(' ', $date_posted[2]);
+ $this->day_posted = $datetime_posted[0];
+ $this->text = $entry["text"];
+ } else {