Guest User

Untitled

a guest
Apr 7th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. <?php
  2. class news{
  3. function __construct() {
  4. $hostname = "localhost";
  5. $username = "root";
  6. $password = "";
  7. $dbname = "news";
  8. $usertable_1 = "news";
  9. $usertable_2 = "users";
  10. $db = mysql_connect( $hostname,$username,$password ) or die( "Fatal error!!!" );
  11. mysql_select_db( $dbname ) or die( mysql_error () );
  12. }
  13. public function _zapr(){
  14. mysql_query( "SET NAMES utf8_general_ci" );
  15. $zapros = "SELECT news.title, news.text_full, news.data_create, users.user_name FROM news LEFT JOIN users ON users.id_user = news.author LIMIT 5";
  16. mysql_query($zapros);
  17. $results = mysql_query( $zapros );
  18. return($results);
  19.  
  20. }
  21.  
  22. }
  23.  
  24. class did extends news {
  25. function _vivod($results){
  26. while( $row = mysql_fetch_assoc ( $results )) {
  27. echo $row['title'].'&nbsp;';
  28. echo $row['data_create'].'<br>';
  29. echo nl2br($row['text_full'].'<br>');
  30. echo '<b>'.$row['user_name'].'</b>';
  31. echo "<hr>";
  32. }
  33.  
  34. }
  35. }
  36. $tt = new did;
  37. $tt->__construct();
  38. $tt->_vivod($tt->_zapr());
Add Comment
Please, Sign In to add comment