Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.90 KB | None | 0 0
  1. <?php
  2.  
  3. include('connect.php');
  4. include('header.php');
  5.  
  6. // If the delete button is pressed
  7. if ( $_GET['action'] == 'delete' ) {
  8.  
  9.     // Check if a post id is set
  10.     // It says: If post_id is something different than empty, move on..
  11.     if ( $_GET['post_id'] != '' ) {
  12.         mysql_query ("DELETE FROM blogg_table WHERE id = '" . $_GET['post_id'] . "'");
  13.     }
  14. }
  15. ?>
  16. <br />
  17. <h1><i>Administration site</i></h1>
  18.  
  19. <?php
  20. // Administrate the blog posts
  21.  
  22.  
  23. $result = mysql_query("SELECT * FROM blogg_table ORDER BY date DESC");
  24.  while($row = mysql_fetch_assoc($result)){
  25.    
  26.   echo '<div class="post">';
  27.        
  28.     echo '<a href="admin.php?action=delete&post_id=' . $row['id'] . '">Slett</a>';
  29.  
  30.   echo '<h2>' .  $row['header'] . '</h2>';
  31.   echo '<h3>' . date ('d. m Y', $row['date']) . '</h3>';
  32.   //echo '<p>' . htmlspecialchars ($row['text']) . '</p>';
  33.  
  34.   echo '<br />';
  35.   echo '<br />';
  36.  
  37.   echo '</div>';
  38.  
  39.  }
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement