douyue1998 2012-06-05 09:47
浏览 13
已采纳

如果该点高于特定金额,则从列中获取值

Okay here's my table structure ,
Name: reward
structure: title , point , hasimg , imgurl

I want to do is , get the title and imgurl(if hasimg=1) when user has points equal to/more than a specific amount.

Here's an example. the reward table is filled with these values(according to above sequence):
1st row: ace , 1000 , 1 , http://imglink.com
2nd row: elite , 2000 , 0 , none
3rd row: pro , 3000 , 1 , http://imglink.com

A user has 3258 points , which is more than 3000 , so he will have the title "pro". So how can i use mysql query to select the "pro" and the imgurl(because hasimg=1) and store them in php variables?

if a user has 2450 points , which is more than 2000 , so he will have the title "2000" , however , it only gets the title but not get the imgurl as hasimg=0.

And how can i make sure the query dosent select 1000 and 2000 as 3000 is more than them?

  • 写回答

1条回答 默认 最新

  • duanduanxi9441 2012-06-05 09:52
    关注

    You basically need the highest point record in table that is less than (or equal to) the userPoints You can use sql query like the following

    select * from rewards where point <= 2300 order by point desc limit 1
    

    once you have the row you can check whether image bit is set and based on that show image or not.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线