diff --git a/includes/classes/page.php b/includes/classes/page.php index fbbf009f..d327e03e 100644 --- a/includes/classes/page.php +++ b/includes/classes/page.php @@ -106,6 +106,10 @@ class Page Create + + + View + Add product diff --git a/includes/classes/user.php b/includes/classes/user.php index 550bfb2d..d7b76c29 100644 --- a/includes/classes/user.php +++ b/includes/classes/user.php @@ -46,9 +46,29 @@ class User $wishlists = $database->query( 'SELECT * FROM wishlists - WHERE user = ' . $_SESSION['user']['id'] . ';' + WHERE user = ' . $this->id . ';' )->fetchAll(); return $wishlists; } + + /** + * Returns a list of products for a given wishlist. + * + * @param int $wishlist + * + * @return array + */ + public function getProducts(int $wishlist): array + { + global $database; + + $products = $database->query( + 'SELECT * + FROM products + WHERE wishlist = ' . $this->id . ';' + )->fetchAll(); + + return $products; + } } diff --git a/includes/pages/wishlist-product-add.php b/includes/pages/wishlist-product-add.php index ead36bd3..4ede777f 100644 --- a/includes/pages/wishlist-product-add.php +++ b/includes/pages/wishlist-product-add.php @@ -7,7 +7,6 @@ */ use wishthis\{Page, User}; -use Embed\Embed; if (isset($_POST['url'], $_POST['wishlist'])) { $database->query('INSERT INTO `products` @@ -16,41 +15,32 @@ if (isset($_POST['url'], $_POST['wishlist'])) { ;'); } -$url = 'https://www.amazon.de/Adventskalender-2020-Schokolade-Weihnachtskalender-346g/dp/B08CTTP5JX'; -$embed = new Embed(); -$info = $embed->get($url); - -// https://github.com/oscarotero/Embed -// echo '
';
-// var_dump($info);
-// echo '
'; - $page = new page(__FILE__, 'Add a product'); $page->header(); $page->navigation(); $user = new User(); ?>
-
-
-

Add a product

+
+
+

Add a product

-
-
- - -
+ +
+ + +
-
- -
+
+ +
- -
+ + +
-
+ */ + +use wishthis\{Page, User}; +use Embed\Embed; + +$page = new page(__FILE__, 'View wishlist'); +$page->header(); +$page->navigation(); + +$products = array(); + +if (isset($_GET['wishlist'])) { + $user = new User(); + $wishlist = $_GET['wishlist']; + $products = $user->getProducts($wishlist); +} +?> +
+
+
+

View wishlist

+

Please select a wishlist to view.

+ +
+ + +
+ +
+ + +
+
+ + + + get($product['url']); + + // https://github.com/oscarotero/Embed + echo '
';
+                // var_dump($info->title);
+                // var_dump($info->description);
+                // var_dump($info->url);
+                // var_dump($info->keywords);
+                echo '
'; + ?> + + + + +
+
+ +footer();