dongshen6060 2016-07-14 12:43
浏览 10
已采纳

PHP中的MySQL无法获得相等的值

I'm trying to make a top users of my website, but the problem that I'm having is if one or more users have the same amount of won games only the first result appears on the website.

Im using this code to search in the database:

$rs1 = mysql_query(SELECT won,steamid,name,avatar,games 
   FROM `users` 
   WHERE won <> 0 
   GROUP BY won DESC LIMIT 18); 
while($row = mysql_fetch_array($rs1))
{ //AND HTML CODE HERE...}

Can someone help me with this? I want to show all the users for example if they have the same number of won games, for example it would show like:

RANK - USER - WON
1    - NAME - 12
2    - NAME - 8
3    - NAME - 8
4    - NAME - 4

BTW I know that I should not use mysql_query but I can't do it another way.

  • 写回答

3条回答 默认 最新

  • douyulv6921 2016-07-14 12:57
    关注

    Seems to me that your GROUP BY should be an ORDER BY

    rs1 = mysql_query(SELECT won,steamid,name,avatar,games 
                   FROM `users` 
                   WHERE won <> 0 
                   ORDER BY won DESC LIMIT 18); 
    

    If that does not work please share the table structure

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c