View Single Post
Old 06-06-2009, 05:10 PM   #6 (permalink)
xenon
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

PHP Code:
class OnlineNowTable extends TableWriter {

    public function 
writeTable() {
        
$query "select username from login where (loggedin > 0) AND (username != '$this->username')";

        
$result mysql_query($query) OR die('Cannot perform OnlineNowTable query!');

        
$str "<table><tr><th>Online Now</th></tr>";

        if (
mysql_num_rows($result) == 0) {        
            
$str .= "<tr><td>nobody online</td></tr>";
        }
        else {
            while(
$row mysql_fetch_array($result))
            {
            
$str .= '<tr><td>'.$row['username'].'</tr></td>';
            }
        }

        
$str .= "</table>";
        
        print 
$str;
    
    }

You don't have $username = 'something' somewhere in the writeTable method, therefore $username is out of scope (meaning it doesn't exist in that method -- function). You want to use the class property $username, which is available through $this->username.
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote