读取记录
按startno排序
如果(上一条记录的endno)+1 = (本记录的startno) 并且type相同则
newstartno = (上一记录的startno);newendno =(本记录的endno)是这个意思吧?
按startno排序
如果(上一条记录的endno)+1 = (本记录的startno) 并且type相同则
newstartno = (上一记录的startno);newendno =(本记录的endno)是这个意思吧?
startno endno type
1 5 1
6 10 1(与上一条记录是连续的)
21 25 1
31 40 2
41 50 2(与上一条记录连续的)
51 60 3(type不同与上一条记录不连续的)
...我想查询出来显示的时候变成
startno endno type
1 10 1
21 25 1
31 50 2
51 60 3
就是将type相同值并且是连号码的两条或多条记录的合并
对同一维的数组进行比较合并(取合并的数组的最大最小值)就可以了
$db->query($query);
while($db->next_record()){
$i++;
$type = $db->f(fd_senbx_type);
$startno = $db->f(fd_senbx_start);
$endno = $db->f(fd_senbx_end);
if($i==1){
$new_voucherid[] = $type;
$new_startno[] = $startno;
$new_endno[] = $endno;
}else{
if( end($new_endno) + 1==$startno && end($new_type)==$type){
array_pop($new_endno);
$new_endno[] = $endno[$i] ;
}else{
$new_voucherid[] = $type;
$new_startno[] = $startno;
$new_endno[] = $endno;
}
}
}
不知这样是否对?