diff --git a/src/inc/database.php b/src/inc/database.php index 57f8fc0..da03ecb 100755 --- a/src/inc/database.php +++ b/src/inc/database.php @@ -195,5 +195,19 @@ class DataBase extends SQLite3 { } return $array; } + + function getPersonas($userid=NULL) { + if(!$userid) { + $userid = $this->getAuthedUserId(); + } + $sql = "SELECT * FROM personas AS persona WHERE userid='$userid' ORDER BY name;"; + + $ret = $this->query($sql); + $array = array(); + while ($row = $ret->fetchArray(SQLITE3_ASSOC)) { + array_push($array, $row); + } + return $array; + } } ?> diff --git a/src/index.php b/src/index.php index 801e3b0..572542d 100755 --- a/src/index.php +++ b/src/index.php @@ -55,12 +55,16 @@ if(!$database) { } else { ?> LOG OUT -
+
- + getPersonas(); + foreach($personas as $persona) { + echo ""; + } + ?>
diff --git a/src/post.php b/src/post.php new file mode 100644 index 0000000..e69d9c0 --- /dev/null +++ b/src/post.php @@ -0,0 +1,14 @@ +getAuthedUserId(); +$persid = $_POST['persona']; // TODO: CHECK OWNERSHIP! (db schema?) +if($userid) { + $db->addPost($_POST['text'], $userid, $persid); +} +header("Location: /"); +?>