commit dec531a7365195933f2a143334c4bfaa2ca3b006 parent c1d8984a2bc8b6de9c5ab4fad60a4cae58df9368 Author: MTRNord <mtrnord1@gmail.com> Date: Sun, 23 Nov 2014 10:36:08 +0100 try to rewrite posts.php for new function Diffstat:
| M | core/backend/blog/posts.php | | | 54 | +++++++++++++++++++++++++++++++++++++++--------------- |
| M | themes/jumbotron/index.php | | | 2 | +- |
2 files changed, 40 insertions(+), 16 deletions(-)
diff --git a/core/backend/blog/posts.php b/core/backend/blog/posts.php @@ -13,24 +13,48 @@ printf("Verbindung fehlgeschlagen: %s\n", mysqli_connect_error()); exit(); } + if (empty($_GET["post_id"])){ + //Check if Data in it + if ($resultat = $connection->query('SELECT * FROM posts')) { + //Put database data in variables + while($daten = $resultat->fetch_object() ){ + $post_id = $daten->id; + $post_title = $daten->title; + $post_text = $daten->text; + $post_author = $daten->author; + $post_date = $daten->date; + $post_categrory = $daten->category; + } + $resultat->close(); + } else { + //If no data in Database give error + echo "Es konnten keine Daten aus der Datenbank ausgelesen werden"; + } + }else{ + //Check if Data in it + if ($resultat = $connection->query('SELECT * FROM posts WHERE id LIKE $post_id')) { + //Put database data in variables + while($daten = $resultat->fetch_object() ){ + $post_id = $daten->id; + $post_title = $daten->title; + $post_text = $daten->text; + $post_author = $daten->author; + $post_date = $daten->date; + $post_categrory = $daten->category; + } + $resultat->close(); + } else { + //If no data in Database give error + echo "Es konnten keine Daten aus der Datenbank ausgelesen werden"; + } + - //Check if Data in it - if ($resultat = $connection->query('SELECT * FROM posts')) { - //Put database data in variables - while($daten = $resultat->fetch_object() ){ - $post_id = $daten->id; - $post_title = $daten->title; - $post_text = $daten->text; - $post_author = $daten->author; - $post_date = $daten->date; - $post_categrory = $daten->category; - } - $resultat->close(); - } else { - //If no data in Database give error - echo "Es konnten keine Daten aus der Datenbank ausgelesen werden"; } + + + + // Close database connection $connection->close(); diff --git a/themes/jumbotron/index.php b/themes/jumbotron/index.php @@ -67,7 +67,7 @@ <div class="container"> <h1> <?php - echo "<a href='#?id=$post_id rel='bookmark'> $post_title </a>"; + echo "<a href='#?id=$post_id' rel='bookmark'> $post_title </a>"; ?> </h1> <div>