dtyqflrr775518 2015-03-07 07:36 采纳率: 100%
浏览 5

基于用户登录在阵列中执行添加的逻辑

I have array like this:

// array of moderator code
Array
(
    [0] => M1
    [1] => M2
    [2] => M3
    [3] => M1
)

// array of commission amount and status based on the above array
Array
(
    [10] => Paid
    [20] => Due
    [30] => Cancelled
    [40] => Paid
)

If any of the moderator logs in, he should see only his commission details and not of others. For example, if M1 logs in, he should see like this in his my account:

OrderCode    PaidAmount    CancelledAmount    DueAmount    Action
    1      50.00 (40 + 10)     0.00             0.00        View

And similarly for other moderators also.

How do I achieve this ?

P.S.: The above arrays are just an example I am trying to understand in order to build my application. In reality, the order will contain any x number of moderators and it's corresponding commission amount and status and are going to be retrieved from the database.

  • 写回答

2条回答 默认 最新

  • doufu5521 2015-03-07 08:15
    关注

    Table Moderators id name Table Commission moderator_id commision_amt commision_status_id

    Table Commission_status status_id name

    when you retrieving the commission for moderator

     select * from Moderators m join Commision c on m.id = c.moderator_id join Commission_status s on c.commistion_status_id = s.status_id where moderator_id = 1(moderator id)
    

    this will give the all commision amounts related to moderator id If any confusion free to comment

    Second part summation of all amounts of one staus sum of all amounts which have specific status like paid and moderator id which logged in

    select sum(commision_amt ) from Moderators m join Commision c on m.id = c.moderator_id join Commission_status s on c.commistion_status_id = s.status_id where moderator_id = 1(moderator id) and status_id =(status_id)
    
    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100