我有两张桌子
1) students
2) fees_paid
Run Code Online (Sandbox Code Playgroud)
学生表如下
id Name
1 xxxxxx
2 yyyyyy
3 zzzzzz
Run Code Online (Sandbox Code Playgroud)
fees_paid如下
id student_id date fees_paid
1 1 02-01-2015 250
2 1 05-01-2015 500
3 2 07-01-2015 400
4 1 06-02-2015 100
5 2 08-02-2015 200
6 3 04-05-2015 1000
Run Code Online (Sandbox Code Playgroud)
我需要一个结果表如下
Name Jan Feb Mar April May
xxxxxx 750 100 0 0 0
yyyyyy 400 200 0 0 0
zzzzzz 0 0 0 0 1000
Run Code Online (Sandbox Code Playgroud)
如何编写mysql查询以获取上述结果集
Js Fiddle:点击这里
我在类的方法中有setInterval().它在创建单个实例时正常工作,但在创建多个实例时失败.创建多个实例时,只有最后创建的实例有效,其他实例停止.
我的脚本如下:
function timer() {
this.ran = Math.floor(Math.random() * 100) + 1;
this.cls = this.ran + '_ocar';
this.div = '<div class="' + this.cls + '">' + this.cls + '</div>';
$('body').append(this.div);
this.run = function() {
thi = this;
thi.k = 0;
setInterval(function() {
console.log(thi.cls);
$('.' + thi.cls).html(thi.k++);
}, 1000);
}
}
one = new timer();
one.run();
setInterval(function() {
new timer().run();
}, 5000);
Run Code Online (Sandbox Code Playgroud)