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.
This commit is contained in:
parent
14ba3f05c8
commit
78a1c42ed1
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
$data = json_decode(file_get_contents('test.json'), true);
|
||||||
|
echo "<div>";
|
||||||
|
foreach($data as $post) {
|
||||||
|
echo '<section class="guestbookpost">';
|
||||||
|
echo "<h4>";
|
||||||
|
echo $post["name"] . "<br>";
|
||||||
|
echo "</h4>";
|
||||||
|
echo '<h4 class="date">';
|
||||||
|
echo $post["date"] . "<br>";
|
||||||
|
echo "</h4>";
|
||||||
|
echo "<p>";
|
||||||
|
echo $post["message"] . "<br>";
|
||||||
|
echo "</p>";
|
||||||
|
echo "</section>";
|
||||||
|
}
|
||||||
|
echo "</div>";
|
||||||
|
?>
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
$dbh = new PDO('sqlite:/home/evan/Development/Website-Redesign/static/guestbook/database.sq3');
|
||||||
|
$data = $dbh->query('SELECT * FROM messages')->fetchAll();
|
||||||
|
rsort($data);
|
||||||
|
foreach($data as $post) {
|
||||||
|
echo '<section class="guestbookpost">';
|
||||||
|
echo "<h4>";
|
||||||
|
echo $post["name"] . "<br>";
|
||||||
|
echo "</h4>";
|
||||||
|
echo '<h4 class="date">';
|
||||||
|
echo $post["date"] . "<br>";
|
||||||
|
echo "</h4>";
|
||||||
|
echo "<p>";
|
||||||
|
echo $post["message"] . "<br>";
|
||||||
|
echo "</p>";
|
||||||
|
echo "</section>";
|
||||||
|
}
|
||||||
|
echo "</div>";
|
||||||
|
?>
|
18
index.html
18
index.html
|
@ -22,23 +22,7 @@
|
||||||
<input type="submit"></input>
|
<input type="submit"></input>
|
||||||
</form>
|
</form>
|
||||||
<?php
|
<?php
|
||||||
$data = json_decode(file_get_contents('test.json'), true);
|
include("fetch-sql.php");
|
||||||
echo "<div>";
|
|
||||||
foreach($data as $post) {
|
|
||||||
echo '<section class="guestbookpost">';
|
|
||||||
echo "<h4>";
|
|
||||||
echo $post["name"] . "<br>";
|
|
||||||
echo "</h4>";
|
|
||||||
echo '<h4 class="date">';
|
|
||||||
echo $post["date"] . "<br>";
|
|
||||||
echo "</h4>";
|
|
||||||
echo "<p>";
|
|
||||||
echo $post["message"] . "<br>";
|
|
||||||
echo "</p>";
|
|
||||||
echo "</section>";
|
|
||||||
}
|
|
||||||
echo "</div>";
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
</main>
|
</main>
|
||||||
<footer>
|
<footer>
|
||||||
|
|
Loading…
Reference in New Issue