Hmm it doesn't like the elseif parts o.O It basically ignores them and uses the last 'if' statement regardless of what $sort is set as. I also tried making them all 'if' statements just in case but then it just uses the last one as the default, regardless of what is input in the database... I also tried using them in the view file (just as a test XD) and it obviously didn't work lol XD
PHP Code:
public function index(){
$mysidia = Registry::get("mysidia");
$total = $mysidia->db->select("owned_adoptables", array("aid"), "owner = '{$mysidia->user->username}'")->rowCount();
$pagination = new Pagination($total, 9, "myadopts");
$pagination->setPage($mysidia->input->get("page"));
$sort = $mysidia->db->select("users", array("sort"), "username = '{$mysidia->user->username}'");
if($sort = 'clicks'){
$stmt = $mysidia->db->select("owned_adoptables", array("aid"), "owner = '{$mysidia->user->username}' ORDER BY totalclicks LIMIT {$pagination->getLimit()},{$pagination->getRowsperPage()}");
}
elseif($sort = 'gender'){
$stmt = $mysidia->db->select("owned_adoptables", array("aid"), "owner = '{$mysidia->user->username}' ORDER BY gender LIMIT {$pagination->getLimit()},{$pagination->getRowsperPage()}");
}
elseif($sort = 'level'){
$stmt = $mysidia->db->select("owned_adoptables", array("aid"), "owner = '{$mysidia->user->username}' ORDER BY currentlevel LIMIT {$pagination->getLimit()},{$pagination->getRowsperPage()}");
}
elseif($sort = 'name'){
$stmt = $mysidia->db->select("owned_adoptables", array("aid"), "owner = '{$mysidia->user->username}' ORDER BY name LIMIT {$pagination->getLimit()},{$pagination->getRowsperPage()}");
}
$this->setField("pagination", $pagination);
$this->setField("stmt", new DatabaseStatement($stmt));
}