Try storing
$this->female->getAdoptID() for the mother and
$this->male->getAdoptID() for the father.
Once that information
exists in the database for a pet, you can also lookup grandparents. (Without calling getAdoptID() again, actually, because it's just pulling the information from a column in the database with the names of whatever you store the mother/father data as. If you store it in the database as 'mother' and 'father' you'll want to pull $this->female->mother, $this->female->father, for example, to get the grandparents on the mother's side.) And then you can store information about the grandparents, too.
PHP Code:
"mother" => $this->female->getAdoptID(),
"father" => $this->male->getAdoptID(),
"grandmotherA" => $this->female->mother,
"grandmotherB" => $this->female->father,
"grandfatherA" => $this->male->mother,
"grandfatherB" => $this->male->father
Allow them to store as 'NULL' in the database if those values don't exist.
On your pet profiles, this will create links to the parents by the names (and if no parent, "---" and it will link to the same pet that it's currently on). I've actually got this sitting in a function in class_ownedadoptable.php, but it shouldn't be too bad to move around elsewhere? (The $this may need to change.)
PHP Code:
$p1name = "---";
$p2name = "---";
if ($this->mother != NULL) { $mother = new OwnedAdoptable($this->mother); $p1name = $mother->name; $p1id = $mother->aid; } else { $p1id = $this->aid; }
if ($this->father != NULL) { $father = new OwnedAdoptable($this->father); $p2name = $father->name; $p2id = $father->aid; } else { $p2id = $this->aid; }
Code:
Parents: <a href='../../levelup/click/".$p1id."'>".$p1name."</a> and <a href='../../levelup/click/".$p2id."'>".$p2name."</a>
For displaying children...
PHP Code:
$children = "";
$babies = array();
$offsprings = explode(",", $this->offsprings);
if ($offsprings != ""){
foreach($offsprings as $offspring){
if ($offspring != 0){
$child = new OwnedAdoptable($offspring);
$babies[] = "<a href='../../levelup/click/".$offspring."'>".$child->name."</a>";
}
}
$children = implode(", ",$babies);
if (empty($children)){ $children = ""; } else {$children = "<br/>Children: ".$children; }
}
Just add the
$children variable wherever you want it, I suggest off the end of parents.
I haven't gotten around to displaying grandparents yet, but it's pretty much the same as for the parents.
(edit: I woke up a few hours later and changed a couple things. Btw, that last chunk of code is hilarious to read out loud when you're super tired.)
(edit later: If using this in
myadoptsview.php instead of making a function to call in
class_ownedadoptable.php, change every instance of
$this-> to
$adopt-> and that's the only difference.)