Guest User

Untitled

a guest
May 26th, 2018
374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.71 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 - list</h1><hr></center>
  8.  
  9. <?php
  10.  
  11.  
  12. //connect to DB
  13. mysql_connect("localhost","root","") or die(mysql_error());
  14. mysql_select_db("news") or die(mysql_error());
  15.  
  16. //query the db
  17. $getnews = mysql_query("SELECT * FROM news ORDER BY id DESC") or die(mysql_query());
  18.  
  19. ?>
  20. <table>
  21.     <tr>
  22.         <td><b>ID #</b></td>
  23.         <td><b>Title</b></td>
  24.     </tr>
  25.     <?php
  26.     while ($row = mysql_fetch_assoc($getnews)) {
  27.     ?>
  28.     <tr>
  29.         <td><?php echo $row['id']; ?></td>
  30.         <td><?php echo $row['title']; ?></td>
  31.     </tr>
  32.     <?php
  33. }
  34. ?>
  35. </table>
  36. </html>
Add Comment
Please, Sign In to add comment