|
Posted by david_longrunner on 11/21/06 23:07
Hi,
I've been programming in PHP for a while and am just trying to tackle
some Object Oriented code for the first time.
I'm starting out by writing a simple phonebook, to display people's
name & phone number from a mysql database.
I've read quite a few tutorials and think I understand classes &
methods, but am just having trouble getting my head around how to set
it all out in code.
Can one of you OO gurus cast your eye over this early code and give me
some feedback? I get the part of setting up a person object and
working from there, but it's the listing part (listing all people in
the phonebook) that I'm struggling with.
Thanks heaps in advance.
dave
class person {
var $firstname;
var $surname;
var $phonenumber;
}
class personListing {
var $listing = array();
function personListing($personarray) {
$sql = "select * from TPEOPLE";
$result = mysql_query($sql);
$this->listing = mysql_fetch_array($result);
}
}
Navigation:
[Reply to this message]
|