在PHP中使用存储过程来获得排名

时间:2017-03-20 07:08:32

标签: php wordpress stored-procedures

我有一个对排行榜表进行排名的商店程序。如何从阵列中提取特定用户标识的等级?这是我执行此查询时我的过程转储的数组:

 $userposition = $wpdb->get_results("CALL addrank"); 
 print_r($userposition);

数组输出:

  

数组([0] => stdClass对象([用户名] => 11 [结果] => 69 [红利]   => 0 [总计] => 69 [等级] => 1)[1] => stdClass对象([userid] => 32 [Result] => 38 [Bonus] => 0 [Total] => 38 [Rank] => 2)[2] =>   stdClass对象([userid] => 37 [结果] => 38 [奖励] => 0 [总计]   => 38 [等级] => 2)[3] => stdClass对象([userid] => 7 [Result] => 38 [Bonus] => 0 [Total] => 38 [Rank] => 2)[4] => stdClass对象(   [userid] => 19 [结果] => 38 [奖金] => 0 [总计] => 38 [等级] => 2)

提前感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

<?php 
foreach($userposition as $row):
    echo $row['userid']." -> ".$row['Rank']."<br>";
endforeach;
?>