rpicms

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

commit ce836a8eb2df3897879f3d9043ca0e68a095cca2
parent f4e917feffbf4facd03b1232a53ef70bb6d2ee67
Author: MTRNord <mtrnord1@gmail.com>
Date:   Sat, 16 May 2015 13:32:05 +0200

add func for delete button

Diffstat:
Mcore/backend/blog/posts.php | 17++++++++++++-----
Mthemes/jumbotron/admin_pages/posts.php | 24+++++++++++++++++++++++-
2 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/core/backend/blog/posts.php b/core/backend/blog/posts.php @@ -1,7 +1,7 @@ <?php /** * Get posts from Database -* +* * This script will the post variables with the database data. * * @author Marcel Radzio <info@nordgedanken.de> @@ -72,7 +72,7 @@ if ($root_3[1] == 'core') { $post_date = $daten->date; $post_category = $daten->category; $post_text_short = shortText($post_text,300); - } + } $resultat->close(); } else { global $id, $connection, $read, $post_id_clean; @@ -106,7 +106,7 @@ if ($root_3[1] == 'core') { $post_date = $daten->date; $post_category = $daten->category; $post_text_short = shortText($post_text,300); - } + } $resultat->close(); } else { global $id, $category, $connection, $read, $category_id_clean; @@ -139,7 +139,7 @@ function read_author(){ $post_date = $daten->date; $post_category = $daten->category; $post_text_short = shortText($post_text,300); - } + } $resultat->close(); } else { global $id, $author, $connection, $read, $author_id_clean; @@ -169,7 +169,15 @@ function shortText($string,$lenght) { } //$longtext = $post_text; +function deletePost($id) { + if ($connection->query(DELETE FROM posts WHERE id=$id) === TRUE) { + echo "Record deleted successfully"; + } else { + echo "Error deleting record: " . $conn->error; + } + $connection->close(); +} @@ -178,4 +186,3 @@ function shortText($string,$lenght) { // Close database connection $connection->close(); - diff --git a/themes/jumbotron/admin_pages/posts.php b/themes/jumbotron/admin_pages/posts.php @@ -16,7 +16,7 @@ echo "<td>$id</td>"; echo "<td>$post_title</td>"; echo "<td></td>"; - echo "<td><a formaction=\"posts.php?function=edit\" title=\"Edit\">Edit</a> <span class=\"glyphicon glyphicon-pencil\" aria-hidden=\"true\"></span> | <a formaction=\"posts.php?function=delete\" title=\"Delete\">Delete</a> <span class=\"glyphicon glyphicon-trash\" aria-hidden=\"true\"></span></td>"; + echo "<td><a formaction=\"posts.php?function=edit&id=$id\" title=\"Edit\">Edit</a> <span class=\"glyphicon glyphicon-pencil\" aria-hidden=\"true\"></span> | <a formaction=\"posts.php?function=delete&id=$id\" title=\"Delete\">Delete</a> <span class=\"glyphicon glyphicon-trash\" aria-hidden=\"true\"></span></td>"; echo "</tr>"; $x = $x+1; $id = $id+1; @@ -24,3 +24,25 @@ } ?> </table> +<?php +if(!empty($_GET['function'])){ + if(!empty($_GET['id'])){ + $get_function = $_GET['function']; + $get_id = $_GET['id']; + if($get_function="edit"){ + + }else{ + deletePost($get_id); + } + + + + + } +} + + + + + +?>