The script will sometimes show the wrong pet when choosing the one with the most clicks

I discovered this problem yesterday, and it's that showing the information of the pet with the most clicks will not always work, but there doesn't seem to be any pattern to when it works and when it doesn't.

I use this code to get the name, name of the owner, and amount of clicks of the most clicked adoptable of that species. It will sometimes pick my pet, which doesn't have the most clicks. The problem is that I have the exact same line of code repeated throughout my php file, and sometimes it works and sometimes it does not.

$adopt = new OwnedAdoptable($topclicks);
Then use the OwnedAdoptable class attributes to fill in everything you need

When you fetch a column you're getting just the data in that cell. If you pick the AID you'll be able to make an OwnedAdoptable. You could also reduce your statement to:
$pet = $mysidia->db->select("owned_adoptables", array(), "Type='{$species}' ORDER BY RAND() LIMIT 1")->fetchObject();

is the same code you provided for the encyclopedia i just removed the: ", "1 from each one and united Type with ORDER, don't know if is the correct way but that's how you can find it in the myadopts.php
and now is displaying the correct info