Backend for songs.zachdecook.com
* Add simple page to view favs
Zach DeCook 2018-11-04
parent 1ae9121 · commit 452b129
-rw-r--r--favs.php16
-rw-r--r--page.php2
2 files changed, 17 insertions, 1 deletions
diff --git a/favs.php b/favs.php
new file mode 100644
index 0000000..ab1e751
--- /dev/null
+++ b/favs.php
@@ -0,0 +1,16 @@
+<a href=".">Go back</a>
+<?php
+$db = new SQLite3( "db/favs.db");
+$name = str_replace("'", "", $_GET['name'] );
+$res = $db->query("SELECT * FROM favorites where name='$name';");
+if ( $res )
+{
+ echo "<ul>";
+ while ( $ar = $res->fetchArray() )
+ {
+ $song = str_replace( "'", "", $ar['song'] );
+ $song = strip_tags( $song );
+ echo "<li><a href='./?song=$song'>$song</a>";
+ }
+ echo "</ul>";
+}
diff --git a/page.php b/page.php
index 8a2805d..d54acbb 100644
--- a/page.php
+++ b/page.php
@@ -198,7 +198,7 @@ function renderFavorite( $number )
if ( $favd )
{
$favd = strip_tags( $favd );
- return "Song in favorites for $favd";
+ return "Song in <a href='favs.php?name=$name'>favorites for $favd</a>";
}
else
{