I'm trying to create a hierarchy of links in a database, and I suspect making it object oriented would make it 500 times easier. Unfortunately, I know very little about OOP. Here's roughly what I want:
Section 1
--Link
--Link
--Link
--Subsection
----Link
--Subsection
----Link
----Link
Section 2
--Link
--Link
Section 3
--Subsection
----Link
----Link
--Subsection
----Link
Users need to be able to add links and even sections and subsections.
Here's what I have so far in terms of the classes:
class GlobalItem {
var $num;
var $title;
var $sentence;
function GlobalItem($title,$sentence) {
$this->title = $title;
$this->sentence = $sentence;
$this->insert_db($title,$sentence,'','','');
}
function insert_db($title,$sentence,$href,$parents,$children) {
$result = mysql_query("INSERT...");
$this->num = mysql_insert_id();
}
}
class GHeader extends GlobalItem() {
var $children;
}
class GSubHeader extends GHeader {
var $parents;
}
class GSubheaderLink extends GSubHeader {
var $href;
}
class GLink extends GlobalItem {
var $parents;
var $href;
}
/end/
Is this roughly what I want? Or am I going about this the wrong way? What would you all recommend. Note that I'm not asking for someone to write this for me--I definitely don't want that. I just haven't got the faintest idea how to do it...how for example would I display such an object? A display function inside the class?
Thanks in advance,
Aciel