我的情况如下输出。
function adjScrollPosition(container, elem) {
var h = container[0].clientHeight;
var w = container[0].clientWidth;
var t = container.scrollTop();
var l = container.scrollLeft();
var b = t + h;
var r = l + w;
elem = elem[0];
var eh = elem.offsetHeight;
var ew = elem.offsetWidth;
var et = elem.offsetTop;
var el = elem.offsetLeft;
var eb = et + eh;
var er = el + ew;
var top = et < t || eh > h ? et : b < eb ? t + (eb - b) : t;
var left = el < l || ew > w ? el : r < er ? l + (er - r) : l;
// If you want to bring element in center of the view port uncomment following lines
//var top = et - (h / 2) + eh;
//var left = el - (w / 2) + ew / 2;
$(container).stop().animate({ scrollTop: top, scrollLeft: left }, 500);
}
我需要的是在显示数据时它应该显示如下格式
Array
(
[0] => Array
(
[day] => Monday
[start_time] => 10:30
[end_time] => 13:30
)
[1] => Array
(
[day] => Monday
[start_time] => 17:30
[end_time] => 19:30
)
[2] => Array
(
[day] => Tuesday
[start_time] => 10:30
[end_time] => 13:30
)
[3] => Array
(
[day] => Tuesday
[start_time] => 17:30
[end_time] => 19:30
)
)
但我得到的是这样的
Monday - 10:30 - 13:30 , 17:30 - 19:30
Tueday - 10:30 - 13:30 , 17:30 - 19:30
这是查询:
Monday - 10:30 - 13:30
Monday - 17:30 - 19:30
Tuesday - 10:30 - 13:30
Tuesday - 17:30 - 19:30
$data['date']= $this->my_model->gettime($hid,$did); // Controller code.
这是php代码:
SELECT day , start_time , end_time FROM date WHERE id='$hid' AND id2='$did'
//查看代码 请帮我这个..........
谢谢是提前
答案 0 :(得分:1)
请在问之前尝试。做一些谷歌你会得到很多相关的答案。
尝试这样:
$arr=array(
array(
'day' => 'Monday',
'start_time' => '17:30',
'end_time' => '19:30'
),
Array
(
'day' => 'Tuesday',
'start_time' => '10:30',
'end_time' => '13:30'
),
Array
(
'day' => 'Tuesday',
'start_time' => '17:30',
'end_time' => '19:30'
),
Array
(
'day' => 'Wednesday',
'start_time' => '10:30',
'end_time' => '13:30'
)
, Array
(
'day' => 'Wednesday',
'start_time' => '17:30',
'end_time' => '19:30'
)
);
$result=array();
foreach($arr as $key=>$value){
if(isset($result[$value['day']])){
$result[$value['day']]=$result[$value['day']]." , ".$value['start_time']."-".$value['end_time'];
}else{
$result[$value['day']]=$value['start_time']."-".$value['end_time'];
}
}
//display....
foreach($result as $key=>$value){
echo $key." - ".$value."<br>";
}