Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8778407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:31:52+00:00 2026-06-13T19:31:52+00:00

I have a problem looping through my tableLegs for a bus timetable to find

  • 0

I have a problem looping through my tableLegs for a bus timetable to find the array of legs legID that the passenger would need to take to get from a to b, take for example the passenger want to start at LocID of c and travel to LocID of p, I would like the array of legs that make up that trip LegID‘s (01, 02, 04), hope that is easy enough to follow.

tableLegs

=============================================
LegID    startLocID   endLocID   departTime
 01          a           e        9:00
 02          e           i        10:00
 03          i           m        11:00
 04          i           q        11:00

tableLegStops

=========================================
LegID     stopNo    LocID     TripTime
  01         1         a       0 min
  01         2         b       20 min
  01         3         c       30 min
  01         4         d       40 min
  01         5         e       60 min
  02         1         e       0 min
  02         2         f       20 min
  02         3         g       30 min
  02         4         h       40 min
  02         5         i       60 min
  03         1         i       0 min
  03         2         j       20 min
  03         3         k       30 min
  03         4         l       40 min
  03         5         m       60 min
  04         1         i       0 min
  04         2         n       20 min
  04         3         o       30 min
  04         4         p       40 min
  04         5         q       60 min

To give you a basis for what I am trying to achieve here, it’s for a bus website where each trip is made up of different legs.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T19:31:53+00:00Added an answer on June 13, 2026 at 7:31 pm

    This task is known as searching for a shortest path in a graph. There exists an implementation of Dijkstra algorithm for solving this in terms of MySQL stored procedure.

    But this would probably require from you to change your table structure a bit, because the graph uses only two types of entities: nodes and edges. So you should decompose your legs into edges, and then deduce the legs back after you get the shortest path in edges.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So i have a problem with taking an array and looping through the values
I have a script that is looping through an array of orders with an
I have a problem with looping through a set of XElements . The behavior
Can anyone please help. I have a problem where I need to loop through
Possible Duplicate: Looping through Markers with Google Maps API v3 Problem I have a
I have a System.Array that I need to convert to string[]. Is there a
So I have this problem while looping through a socket with a while loop.
Am try to looping through a database result set, the problem is that i
Thanks for looking on this problem. I have a page that is totally valid
I have a for loop looping through an ArrayList . If a condition is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.