php with two class
<p>my sample is good or not?
I have a good connection to the database, or too should be in the class?</p>

<p>Thanks</p>

<pre><code>&lt;?php
mysql_connect('localhost','root','admin');
mysql_select_db('test');

class UserDisplay
{
    function getDisplayName()
    {
        $sql = 'select first_name, last_name, display_name from users where user_id = "3"';
        $results = mysql_query($sql);
        $row = mysql_fetch_array($results);
        $this-&gt;user_id = $user_id;

        return $this-&gt;user_id;
    }
}

class UserInsert

    function InsertName($name)
    {
        mysql_query("INSERT INTO Persons (first_name)VALUES ('".$name."')");
    }
}

$userD = new UserDisplay();
echo "User known as: " . $userD-&gt;getDisplayName() . "\n";

$userI = new UserInsert();
$userI-&gt;InsertName("Peter");
?&gt;
</code></pre>
