This tool allows you to search for interstate bus schedules between two cities. Here's a breakdown of the functionality:
The user interface consists of two input fields: "Source City" and "Destination City". As you type in each field, the system provides suggestions to help you select the correct city. A "Search" button initiates the search process.
As you type in the source or destination city fields, the tool sends a request to the backend to retrieve city suggestions based on your input. This is achieved by calling the index.php?suggest
endpoint. The backend uses a SQL query to match your input against a list of known cities from the bus_routes
table. The matching is case-insensitive and returns any city that contains your input as a substring. The suggestions are displayed in a dropdown-like box below the input field.
When you click the "Search" button, the tool sends a request to the backend with the source and destination cities. This is done by calling the index.php?search
endpoint with the city names as query parameters. The backend then searches the bus schedule data for matches. The matching is case-insensitive.
The backend retrieves the bus schedules from the bus_routes
table in the MySQL database. It filters the schedules based on the provided source and destination cities and the selected date. The matching is case-insensitive, using LIKE '%$city%'
in the SQL query.
The results are displayed in a table format, showing the bus company, source, destination, departure time, arrival time, and price for each matching schedule. If no schedules are found, a message is displayed indicating that no schedules are available for the selected cities.
The backend is built using PHP and connects to a MySQL database. It provides two API endpoints:
index.php?search
: Handles the bus schedule search.index.php?suggest
: Handles the city suggestions.The backend retrieves the bus schedule data from the bus_routes
table. Input sanitization is performed to prevent SQL injection attacks.
This tool can be scaled by optimizing the database queries, using caching mechanisms, and deploying the application on a cloud platform. Future enhancements could include: