Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>News</title>
- <meta content="text/html; charset=UTF-8" http-equiv="content-type">
- <link rel="stylesheet" href="style.css" type="text/css">
- </head>
- <center><h1>News</h1>
- <hr></center>
- <?php
- //connect to DB
- mysql_connect("localhost","root","") or die(mysql_error());
- mysql_select_db("news") or die(mysql_error());
- //query the db
- $getnews = mysql_query("SELECT * FROM news ORDER BY id DESC") or die(mysql_query());
- while ($row = mysql_fetch_assoc($getnews))
- {
- //get data
- $id = $row['id'];
- $title = $row['title'];
- $body = $row['body'];
- $date = $row['date'];
- echo "
- <b><center>$title posted on $date</b></center><br>
- ";
- echo nl2br("<center>$body</center>");
- echo "<hr>";
- }
- ?>
- </html>
Add Comment
Please, Sign In to add comment