Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # If we have results
- if($Count_Routes > 0){
- # Creating results
- $Routes = array();
- $Quick = array();
- # Array variables
- $currentGroup = 0;
- $groupSize = 100;
- $i=0;
- $z=0;
- $Cur_Bus=null;
- while($Assoc_Routes = mysql_fetch_assoc($Query_Routes)){
- $z++;
- # Array from Database
- $Routes[] = $Assoc_Routes;
- # Routes table
- # If there's no entry
- if(count($Quick) == 0){
- $Quick[]['from'] = $Assoc_Routes['route_id'];
- }
- # Check if it's a new group
- if($Assoc_Routes['route_id'] >= $currentGroup+$groupSize && $groupSize != 0) {
- # Count
- $i++;
- # Update current group
- $currentGroup = floor((int)$Assoc_Routes['route_id']/$groupSize)*$groupSize;
- # Add last route of last group in last entry
- $Quick[$i-1]['to'] = $Cur_Bus;
- # Add new route to this new group
- $Quick[]['from'] = $Assoc_Routes['route_id'];
- }
- # Current loop, will be see in the last if
- $Cur_Bus = $Assoc_Routes['route_id'];
- # If we are done looping (last loop), add last bus to the group
- if($Count_Routes == $z){
- $Quick[$i]['to'] = $Cur_Bus;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement