View Single Post
  #2  
Old 02-09-2016, 02:38 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 88,998
Kyttias is on a distinguished road
Default

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.)
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.

Last edited by Kyttias; 02-11-2016 at 11:39 PM.
Reply With Quote