From 78a1c42ed157c142e66146f1ef7aa6912596c8f0 Mon Sep 17 00:00:00 2001 From: "Evan G." Date: Mon, 10 Jun 2024 16:04:25 -0500 Subject: [PATCH] Seperate Fetch-JSON and fetch-SQL This seperates the two HTML fetches to fetch-sql.php and fetch-json.php, this even means I could use both, or even provide an option to select between the submisson types. I think that however would be too much for me to maintain, so I will only use one or another. I do want to work on the datatype, and using .ini configuration for SQL and for selecting the datatype by default. If there are optimzations I can make to my SQL querys, I will try to implment those, however I know of none such optimzations. --- fetch-json.php | 18 ++++++++++++++++++ fetch-sql.php | 19 +++++++++++++++++++ index.html | 18 +----------------- 3 files changed, 38 insertions(+), 17 deletions(-) create mode 100644 fetch-json.php create mode 100644 fetch-sql.php diff --git a/fetch-json.php b/fetch-json.php new file mode 100644 index 0000000..4dbbdba --- /dev/null +++ b/fetch-json.php @@ -0,0 +1,18 @@ +"; + foreach($data as $post) { + echo '
'; + echo "

"; + echo $post["name"] . "
"; + echo "

"; + echo '

'; + echo $post["date"] . "
"; + echo "

"; + echo "

"; + echo $post["message"] . "
"; + echo "

"; + echo "
"; + } + echo ""; +?> diff --git a/fetch-sql.php b/fetch-sql.php new file mode 100644 index 0000000..c7bbcec --- /dev/null +++ b/fetch-sql.php @@ -0,0 +1,19 @@ +query('SELECT * FROM messages')->fetchAll(); +rsort($data); +foreach($data as $post) { + echo '
'; + echo "

"; + echo $post["name"] . "
"; + echo "

"; + echo '

'; + echo $post["date"] . "
"; + echo "

"; + echo "

"; + echo $post["message"] . "
"; + echo "

"; + echo "
"; + } + echo ""; +?> diff --git a/index.html b/index.html index c491c2f..1dfb184 100644 --- a/index.html +++ b/index.html @@ -22,23 +22,7 @@ "; - foreach($data as $post) { - echo '
'; - echo "

"; - echo $post["name"] . "
"; - echo "

"; - echo '

'; - echo $post["date"] . "
"; - echo "

"; - echo "

"; - echo $post["message"] . "
"; - echo "

"; - echo "
"; - } - echo ""; - + include("fetch-sql.php"); ?>