Guest User

Untitled

a guest
Apr 20th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. <?php
  2. $mysql_hostname = 'localhost';
  3. $mysql_username = 'root';
  4. $mysql_password = 'password';
  5. $mysql_database = 'test';
  6.  
  7. mysql_connect($mysql_hostname, $mysql_username, $mysql_password) or die(mysql_error());
  8. mysql_select_db($mysql_database);
  9.  
  10. class news {
  11. function post( $title, $content ) {
  12. return '<a href="#"><h2>'.$title.'</h2></a>'.
  13. '<p>'.$content.'</p>';
  14. }
  15.  
  16. function show( $amount ) {
  17. return '<p>show '.$amount.'</p>';
  18.  
  19. $query = mysql_query('SELECT id, date, title, content FROM archive ORDER BY date DESC, time DESC LIMIT '.$amount);
  20. while ($fetch = mysql_fetch_array($query, MYSQL_ASSOC)) {
  21. echo '<a id="'.$fetch['id'].'"><h2>'.$fetch['title'].'</h2></a>';
  22. echo '<p>'.$fetch['content'].'</p>';
  23. }
  24. }
  25. }
  26. ?>
Add Comment
Please, Sign In to add comment