我一直在尝试根据分数获得用户的百分等级。我可以在 phpmyadmin 中获得结果 - 但似乎无法在 php 中获得正确的代码......
这是我到目前为止所拥有的......
$db=JFactory::getDBO();
$session =& JFactory::getSession();
$user =& JFactory::getUser();
$userId = $user->id;
$rank = "SELECT rank, cb_cscore,(SELECT 100*(rank / count(*)) FROM `e72jm_comprofiler`,(SELECT @rownum :=0)r WHERE cb_cscore IS NOT NULL) as percentage FROM (SELECT @rownum := @rownum +1 AS rank, `cb_cscore` , `user_id` FROM `e72jm_comprofiler`,(SELECT @row :=0) r WHERE cb_cscore IS NOT NULL AND user_id = $userId LIMIT 0,1";
$db->setQuery( $rank );
$db->query();
但是 - 我一直卡在如何加载结果......
意思是如何从查询中加载结果.....
任何帮助将不胜感激...