Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- FINAL CODE for the DATABASE-DRIVEN, PHP/MySQL VERSION of Erik's Blog
- */
- function makePost( $title , $body )
- {
- $output = '
- <div id="post_n" class="post">
- <h2>'.$title.'</h2>
- <p>'.$body.'</p>
- </div>
- ';
- return $output;
- }
- $username = 'root';
- $password = '';
- $location = 'localhost';
- $database = 'blog';
- $cnxn = mysql_connect( $location , $username , $password );
- @mysql_select_db( $database ) or die( "Error selecting database" );
- ?>
- <html>
- <head>
- </head>
- <body>
- <h1>Erik’s Blog</h1>
- <?php
- $query = "SELECT * FROM Posts ORDER BY post_id;";
- $results = mysql_query( $query );
- while( $row = mysql_fetch_assoc($results) )
- {
- print makePost( $row['title'] , $row['body'] );
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement