Advertisement
spacechase0

Posts

Jan 30th, 2014
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.59 KB | None | 0 0
  1. <?php
  2.  
  3. // posts.php
  4. $idCounter = 0;
  5. $posts = array();
  6. $posts[ $idCounter++ ] = array( 'title' => 'Some Post', 'content' => '...' );
  7. $posts[ $idCounter++ ] = array( 'title' => 'Another Post', 'content' => '.....' );
  8. // ...
  9.  
  10. // postListing.php
  11. require_once( 'posts.php' );
  12. foreach ( $posts as $id -> $post )
  13. {
  14.     echo( '<h1><a href="post.php?id=' . $id . '">' . $post[ 'title' ] . '</a></h1>' );
  15. }
  16.  
  17. // viewPost.php
  18. if ( !isset( $posts[ $_GET[ 'id' ] ] ) die( "No such post" );
  19.  
  20. $post = $posts[ $_GET[ 'id' ] ];
  21. echo( '<h1>' . $post[ 'title' ] . '</h1>' );
  22. echo( $post[ 'title' ] );
  23.  
  24. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement