rpicms

A CMS for the Raspberry Pi
git clone git://archive.git.mtrnord.blog/RpicmsTeam/rpicms.git
Log | Files | Refs | README | LICENSE

commit 1ab7b5f5cc8e641c4eca0aa2c855b5688e032675
parent 4c4fdb9cfcb95cd18a341dca1bd67172fc456f6c
Author: MTRNord <mtrnord1@gmail.com>
Date:   Mon,  1 Dec 2014 17:33:37 +0100

updated posts.php for category function

Diffstat:
Mcore/backend/blog/posts.php | 39++++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)

diff --git a/core/backend/blog/posts.php b/core/backend/blog/posts.php @@ -21,9 +21,13 @@ #$resultat->close(); } next_id_only(); + next_id_category(); + function next_id_category(){ + read_category(); + } function next_id_only(){ read_only(); - } + } function read_only(){ global $id, $connection, $read, $post_id_clean; global $post_id, $post_title, $post_text, $post_author, $post_date, $post_categrory, $post_text_short; @@ -57,6 +61,39 @@ } + function read_category(){ + global $id, $connection, $read, $post_id_clean; + global $post_id, $post_title, $post_text, $post_author, $post_date, $post_categrory, $post_text_short; + if ($resultat = $connection->query("SELECT * FROM posts WHERE category LIKE '$category' ")) { + //echo 'SELECT * FROM posts WHERE id LIKE '.$id; + //Put database data in variables + while($daten = $resultat->fetch_object() ){ + //var_dump ($daten); + $post_id = $daten->id; + $post_title = $daten->title; + $post_text = $daten->text; + $post_author = $daten->author; + $post_date = $daten->date; + $post_categrory = $daten->category; + $post_text_short = shortText($post_text,300); + } + $resultat->close(); + } else { + global $id, $connection, $read, $post_id_clean; + global $post_id, $post_title, $post_text, $post_author, $post_date, $post_categrory; + global $error; + $error = "1"; + echo "Nothing to read from Database!"; + $post_id = "Database error!"; + $post_title = "Database error!"; + $post_text = "Database error!"; + $post_author = "Database error!"; + $post_date = "Database error!"; + $post_categrory = "Database error!"; + } + } + + function shortText($string,$lenght) { if(strlen($string) > $lenght) {