Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2011
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. # If we have results
  2. if($Count_Routes > 0){
  3. # Creating results
  4. $Routes = array();
  5. $Quick = array();
  6.  
  7. # Array variables
  8. $currentGroup = 0;
  9. $groupSize = 100;
  10. $i=0;
  11. $z=0;
  12. $Cur_Bus=null;
  13.  
  14. while($Assoc_Routes = mysql_fetch_assoc($Query_Routes)){
  15. $z++;
  16. # Array from Database
  17. $Routes[] = $Assoc_Routes;
  18.  
  19. # Routes table
  20. # If there's no entry
  21. if(count($Quick) == 0){
  22. $Quick[]['from'] = $Assoc_Routes['route_id'];
  23. }
  24.  
  25. # Check if it's a new group
  26. if($Assoc_Routes['route_id'] >= $currentGroup+$groupSize && $groupSize != 0) {
  27. # Count
  28. $i++;
  29.  
  30. # Update current group
  31. $currentGroup = floor((int)$Assoc_Routes['route_id']/$groupSize)*$groupSize;
  32.  
  33. # Add last route of last group in last entry
  34. $Quick[$i-1]['to'] = $Cur_Bus;
  35.  
  36. # Add new route to this new group
  37. $Quick[]['from'] = $Assoc_Routes['route_id'];
  38. }
  39.  
  40. # Current loop, will be see in the last if
  41. $Cur_Bus = $Assoc_Routes['route_id'];
  42.  
  43. # If we are done looping (last loop), add last bus to the group
  44. if($Count_Routes == $z){
  45. $Quick[$i]['to'] = $Cur_Bus;
  46. }
  47. }
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement