Guest User

Untitled

a guest
May 26th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>News</title>
  4. <meta content="text/html; charset=UTF-8" http-equiv="content-type">
  5. <link rel="stylesheet" href="style.css" type="text/css">
  6. </head>
  7. <center><h1>News</h1>
  8. <hr></center>
  9.  
  10. <?php
  11.  
  12.  
  13. //connect to DB
  14. mysql_connect("localhost","root","") or die(mysql_error());
  15. mysql_select_db("news") or die(mysql_error());
  16.  
  17. //query the db
  18. $getnews = mysql_query("SELECT * FROM news ORDER BY id DESC") or die(mysql_query());
  19.  
  20. while ($row = mysql_fetch_assoc($getnews))
  21. {
  22.  
  23. //get data
  24. $id = $row['id'];
  25. $title = $row['title'];
  26. $body = $row['body'];
  27. $date = $row['date'];
  28.  
  29. echo "
  30. <b><center>$title posted on $date</b></center><br>
  31. ";
  32.  
  33. echo nl2br("<center>$body</center>");
  34.  
  35. echo "<hr>";
  36.  
  37. }
  38.  
  39. ?>
  40.  
  41. </html>
Add Comment
Please, Sign In to add comment