Part on rendering notes finished
This commit is contained in:
parent
efdfb02518
commit
3f7c7ef7dd
7 changed files with 58 additions and 4 deletions
11
controllers/note.php
Normal file
11
controllers/note.php
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
$username = 'appUser';
|
||||||
|
$password = 'password';
|
||||||
|
$config = require('config.php');
|
||||||
|
$db = new Database($config['database'], $username, $password);
|
||||||
|
|
||||||
|
$heading = "Note";
|
||||||
|
|
||||||
|
$note = $db->query('select * from notes where id = :id', ['id' => $_GET['id']] )->fetch();
|
||||||
|
//dd($notes);
|
||||||
|
require "views/note.view.php";
|
||||||
11
controllers/notes.php
Normal file
11
controllers/notes.php
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
$username = 'appUser';
|
||||||
|
$password = 'password';
|
||||||
|
$config = require('config.php');
|
||||||
|
$db = new Database($config['database'], $username, $password);
|
||||||
|
|
||||||
|
$heading = "My Notes";
|
||||||
|
|
||||||
|
$notes = $db->query('select * from notes where user_id = 1')->fetchAll();
|
||||||
|
//dd($notes);
|
||||||
|
require "views/notes.view.php";
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
require 'functions.php';
|
require 'functions.php';
|
||||||
require 'Database.php';
|
require 'Database.php';
|
||||||
//require 'router.php';
|
require 'router.php';
|
||||||
$username = 'appUser';
|
$username = 'appUser';
|
||||||
$password = 'password';
|
$password = 'password';
|
||||||
$config = require('config.php');
|
$config = require('config.php');
|
||||||
|
|
@ -16,4 +16,4 @@ $posts = $db->query($query, [$id])->fetchAll(PDO::FETCH_ASSOC);
|
||||||
// Beide Varianten machen inhaltlich das Gleiche.
|
// Beide Varianten machen inhaltlich das Gleiche.
|
||||||
// freie Wahl, welche der beiden Varianten bevorzugt wird.
|
// freie Wahl, welche der beiden Varianten bevorzugt wird.
|
||||||
|
|
||||||
dd($posts);
|
//dd($posts);
|
||||||
|
|
@ -6,7 +6,9 @@ $routes = [
|
||||||
'/about' => 'controllers/about.php',
|
'/about' => 'controllers/about.php',
|
||||||
'/contact' => 'controllers/contact.php',
|
'/contact' => 'controllers/contact.php',
|
||||||
'/mission' => 'controllers/mission.php',
|
'/mission' => 'controllers/mission.php',
|
||||||
'/mathe' => 'controllers/mathe.php'
|
'/mathe' => 'controllers/mathe.php',
|
||||||
|
'/note' => 'controllers/note.php',
|
||||||
|
'/notes' => 'controllers/notes.php'
|
||||||
];
|
];
|
||||||
|
|
||||||
function routeToController($uri, $routes) {
|
function routeToController($uri, $routes) {
|
||||||
|
|
|
||||||
12
views/note.view.php
Normal file
12
views/note.view.php
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?php require ('partials/head.php') ?>
|
||||||
|
<?php require ('partials/nav.php') ?>
|
||||||
|
<?php require ('partials/banner.php') ?>
|
||||||
|
<main>
|
||||||
|
<div class="mx-auto max-w-7xl py-6 sm:px-6 lg:px-8">
|
||||||
|
<p class="mb-6">
|
||||||
|
<a href="/notes" class="text-blue-500 hover:underline">go back</a>
|
||||||
|
</p>
|
||||||
|
<p><?= $note['body'] ?></p>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
<?php require ('partials/footer.php') ?>
|
||||||
15
views/notes.view.php
Normal file
15
views/notes.view.php
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?php require ('partials/head.php') ?>
|
||||||
|
<?php require ('partials/nav.php') ?>
|
||||||
|
<?php require ('partials/banner.php') ?>
|
||||||
|
<main>
|
||||||
|
<div class="mx-auto max-w-7xl py-6 sm:px-6 lg:px-8">
|
||||||
|
<?php foreach ($notes as $note) : ?>
|
||||||
|
<li>
|
||||||
|
<a href="/note?id=<?= $note['id'] ?>" class="text-blue-500 hover:underline">
|
||||||
|
<?= $note['body'] ?>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
<?php require ('partials/footer.php') ?>
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
<a href="/mathe" class="<?= urlIs('/mathe') ? 'bg-gray-900 text-white' : 'text-gray-300' ?> hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium">Mathe</a>
|
<a href="/mathe" class="<?= urlIs('/mathe') ? 'bg-gray-900 text-white' : 'text-gray-300' ?> hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium">Mathe</a>
|
||||||
|
|
||||||
|
<a href="/notes" class="<?= urlIs('/notes') ? 'bg-gray-900 text-white' : 'text-gray-300' ?> hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium">Notes</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -50,14 +51,16 @@
|
||||||
From: "transform opacity-100 scale-100"
|
From: "transform opacity-100 scale-100"
|
||||||
To: "transform opacity-0 scale-95"
|
To: "transform opacity-0 scale-95"
|
||||||
-->
|
-->
|
||||||
|
<!--
|
||||||
<div class="absolute right-0 z-10 mt-2 w-48 origin-top-right rounded-md bg-white py-1 shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none" role="menu" aria-orientation="vertical" aria-labelledby="user-menu-button" tabindex="-1">
|
<div class="absolute right-0 z-10 mt-2 w-48 origin-top-right rounded-md bg-white py-1 shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none" role="menu" aria-orientation="vertical" aria-labelledby="user-menu-button" tabindex="-1">
|
||||||
<!-- Active: "bg-gray-100", Not Active: "" -->
|
Active: "bg-gray-100", Not Active: ""
|
||||||
<a href="#" class="block px-4 py-2 text-sm text-gray-700" role="menuitem" tabindex="-1" id="user-menu-item-0">Your Profile</a>
|
<a href="#" class="block px-4 py-2 text-sm text-gray-700" role="menuitem" tabindex="-1" id="user-menu-item-0">Your Profile</a>
|
||||||
|
|
||||||
<a href="#" class="block px-4 py-2 text-sm text-gray-700" role="menuitem" tabindex="-1" id="user-menu-item-1">Settings</a>
|
<a href="#" class="block px-4 py-2 text-sm text-gray-700" role="menuitem" tabindex="-1" id="user-menu-item-1">Settings</a>
|
||||||
|
|
||||||
<a href="#" class="block px-4 py-2 text-sm text-gray-700" role="menuitem" tabindex="-1" id="user-menu-item-2">Sign out</a>
|
<a href="#" class="block px-4 py-2 text-sm text-gray-700" role="menuitem" tabindex="-1" id="user-menu-item-2">Sign out</a>
|
||||||
</div>
|
</div>
|
||||||
|
-->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue