Guest User

Untitled

a guest
Apr 23rd, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 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. $query = mysql_query('SELECT id, date, title, content FROM archive ORDER BY date DESC, time DESC LIMIT '.$amount);
  18. while ($fetch = mysql_fetch_array($query, MYSQL_ASSOC)) {
  19. return '<a id="'.$fetch['id'].'"><h2>'.$fetch['title'].'</h2></a>'.
  20. '<p>'.$fetch['content'].'</p>';
  21. }
  22. return '<p>show '.$amount.'</p>';
  23. }
  24. }
  25. ?>
Add Comment
Please, Sign In to add comment