View Single Post
  #2  
Old 03-05-2016, 10:14 AM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 127,237
Kyttias is on a distinguished road
Default

I made a mod that allows for a more customizable index page (rather than using the AdminCP), and it will allow you to use PHP. In the mod I also included example code for displaying five random pets. Check it out!

The exact code snippet for the random pets is this:
PHP Code:
$document->add(new Comment("<div class='row'><h4>Random 5 Pets</h4>"FALSE));
        
$stat_rand5 $mysidia->db->select("owned_adoptables", array("aid"), "1 ORDER BY RAND() DESC LIMIT 5");        
        while(
$aid $stat_rand5->fetchColumn()){
            
$adopt = new OwnedAdoptable($aid);    
            
$document->add(new Comment("
                <div style='display: inline-table; text-align: center;'>
                <a href='levelup/click/
{$adopt->getAdoptID()}'><img src='{$adopt->getImage()}'></a></br>
                  <a href='levelup/click/
{$adopt->getAdoptID()}'><b>{$adopt->getName()}</b></a> the <small><b>LVL.</b> {$adopt->getCurrentLevel()}</small> {$adopt->getType()}</div>
              "
FALSE));
        }
        
$document->add(new Comment("</div>"FALSE)); 
If you want three instead of five, all you have to do is edit "1 ORDER BY RAND() DESC LIMIT 5" to "1 ORDER BY RAND() DESC LIMIT 3".
__________________
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.
Reply With Quote