Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class news{
- function __construct() {
- $hostname = "localhost";
- $username = "root";
- $password = "";
- $dbname = "news";
- $usertable_1 = "news";
- $usertable_2 = "users";
- $db = mysql_connect( $hostname,$username,$password ) or die( "Fatal error!!!" );
- mysql_select_db( $dbname ) or die( mysql_error () );
- }
- public function _zapr(){
- mysql_query( "SET NAMES utf8_general_ci" );
- $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";
- mysql_query($zapros);
- $results = mysql_query( $zapros );
- return($results);
- }
- }
- class did extends news {
- function _vivod($results){
- while( $row = mysql_fetch_assoc ( $results )) {
- echo $row['title'].' ';
- echo $row['data_create'].'<br>';
- echo nl2br($row['text_full'].'<br>');
- echo '<b>'.$row['user_name'].'</b>';
- echo "<hr>";
- }
- }
- }
- $tt = new did;
- $tt->__construct();
- $tt->_vivod($tt->_zapr());
Add Comment
Please, Sign In to add comment