HTML and MYSQL Provider Lookup Application Your client the M
HTML and MYSQL
Provider Lookup Application
Your client, the Michigan Association of Independent Music Educators, represents individuals who offer musical training in piano, singing, guitar, violin, and accordion.
The client has commissioned a provider search tool to help people find their membership.
A consumer will enter a zip code, and will be provided with a list of all association members within a 25-mile range with relevant details.
The client will supply a database of members and locations, and will pay $450 for a complete application.
Specifications
Create a single-page application with an HTML form and database.
The form will include the following:
Input text field for Zip Code
Submit button
The zip code text field must retain its value after form is submitted.
If an invalid zip code is entered, display an error message.
An invalid zip code is a string that is not made up of 5 digits.
Hint: Use the is_numeric and strlen functions.
If a valid zip code is entered, but not found in the database, display an appropriate message.
If a valid zip code is entered and is found in the database but no people are found within 25 miles, display an appropriate message.
When a valid zip code is entered and people are found within 25 miles, display a report comprised of the following:
Report heading:
Display information about the location selected:
zip code
city
state
the total number of association members within 25 miles
Report Matches:
A table displaying information about the nearby people, with these columns:
Person
Provider number
City
State
Zip
The distance from the selected location. (in miles)
The table will be sorted by distance, closest on top.
Secondary sorting is by provider number
Implementation Details
Use the a6_locations and a6_people tables.
Find the one record in the a6_locations table that matches the entered zip code.
Use this information for your report heading, and to set the $lat and $log variables mentioned below.
Join the two tables together using locationID
To find locations that are within 25 miles, use this formula:
I have two variables, $lat and $log, representing the latitude and longitude from the record found in step 2.
My WHERE clause would be:
WHERE 69*(sqrt(pow($lat-latitude,2) + pow($log-longitude,2))) < 25
sqrt is the MySQL function for square root, and pow is the MySQL function for \"to the power of\".
Solution
<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">
<html>
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">
<title>provider lookup application</title>
<%
//All the parameters to be get from the request header itself when you click the search button.
String zip = request.getParameter(\"zip\");
String distance = request.getParameter(\"distance\");
String toDo = request.getParameter(\"toDo\");
String contextPath = request.getContextPath();
String container = null;
//Object for the ResultsBuilder class which builds the result in a table format by executing the buildSearchResults(int , int)
ResultsBuilder builder = new ResultsBuilder();
if(toDo != null && toDo.equals(\"search\")) {
container = builder.buildSearchResults(zip,distance);
}
%>
<script>
function search() {
var zip = document.getElementById(\"zip\").value;
var dist = document.getElementById(\"dist\").value;
//Pass the entered values in the url format and assigns the url to the current window.
var url = \"<%=contextPath%>\"+\"/jsp/providerlookupapplication.jsp?zip=\"+zip+\"&distance=\"+dist+\"&toDo=\"+search+\";
window.location.assign(url);
}
</script>
</head>
<body>
//form to enter the zip and the maximum distance
<input id = \"zip\" name = \"zip\" type = \"text\">
<select id = \"dist\" name = \"within\">
<option value = \"25\">25 miles</option>
<option value = \"50\">50 miles</option>
<option value = \"75\">75 miles</option>
</select>
//When the user clicks on search button search() functions gets executed which was written in the script tag.
<input type = \"button\" value = \"Search\" onclick = \"search()\">
//container contains the two tables which were generated by executing the buildSearchResults() function.
<div id=\"container\" ><%=container%></div>
<br/>
<br/>
</body>
</html>
I provided the Jsp code for your Application. The only task pending for you is to write ResultsBuilder class .
In that class you have to write buildSearchResults() function that takes two parameters zip and the distance and return the results. You have to build the Html table with the obtained results and return as string.
Then your code will work.


