View Single Post
  #2  
Old 05-30-2017, 02:41 PM
Dinocanid's Avatar
Dinocanid Dinocanid is offline
Member
 
Join Date: Aug 2016
Location: Maryland, USA
Posts: 516
Gender: Unknown/Other
Credits: 68,543
Dinocanid is on a distinguished road
Default

To filter which pets show up in the dropdown, you use this for the conditions:
PHP Code:
$stmt $mysidia->db->select("owned_adoptables", array("name""aid"), "owner = '{$mysidia->user->username}' AND column = value"); 
So you would replace 'column' and 'value' with whatever you want. (you can use AND as much as you want too if you wanted to narrow it down further) Here is an example if it being used to only select pets that are level 3 or higher:
PHP Code:
$stmt $mysidia->db->select("owned_adoptables", array("name""aid"), "owner = '{$mysidia->user->username}' AND currentlevel >= 3"); 
And here is an example found in breeding.php, which narrows down the list to pets of a certain gender, level, and last time bred:
PHP Code:
$stmt $mysidia->db->select("owned_adoptables", array("name""aid"), "owner = '{$mysidia->user->username}' AND gender = 'f' AND currentlevel >= {$settings->level} AND lastbred <= '{$lasttime}'"); 
For getting the id of the pet, you have to use 'fetchmap', like this:
PHP Code:
$stmt $mysidia->db->select("owned_adoptables", array("name""aid"), "owner = '{$mysidia->user->username}' AND currentlevel >= 3");
        
$adopts $mysidia->db->fetchMap($stmt);
//code...
$petlist = new DropdownList("petlist");
          
$petlist->add(new Option("None Selected""none"FALSE));            
          
$petlist->fill($adopts);
$yourForm->add($petlist); 
That way the pet id is inserted into the database instead of the name, unlike it would've done if you used 'fetchlist', which would get the name but nothing else.
__________________
Reply With Quote