geocoder - search feature

By shawnpatoka - October 17, 2012

Is there a way i can have the search box on one page, so users can type in a zipcode and when they hit enter, it brings them to a new page displaying the results?

Re: [shawnpatoka] geocoder - search feature

By gregThomas - October 17, 2012

Have you had a look at the sample_search.php example that comes with the geocoder? This allows the user to type in there zip code, and can be used to only display results that are within a certain distance of them. Are you looking for a search that is more specific than this?

Thanks!
Greg Thomas







PHP Programmer - interactivetools.com

Re: [greg] geocoder - search feature

By shawnpatoka - October 17, 2012

yeah, i am working off of the sample_search.php but i want to set up my site so that the search box is on default.php and displays the results on list.php

Re: [shawnpatoka] geocoder - search feature

By gregThomas - October 17, 2012

Hi,

This should be fairly straight forward. If you copy the search form from sample_search.php and place it on your default.php page, and then change the action in the form tag to list.php. Now when the form submits it will submit to list.php.

<form method="post" action="list.php">
<input type="hidden" name="search" value="1" />
<input type="text" name="fromAddress" value="<?php echo htmlspecialchars(@$_REQUEST['fromAddress']); ?>" size="30" />

<select name="maxDistance">
<option value="">at any distance</option>
<option value="100" <?php selectedIf(100, @$_REQUEST['maxDistance']) ?> >within 100 miles</option>
<option value="25" <?php selectedIf( 25, @$_REQUEST['maxDistance']) ?> >within 25 miles</option>
<option value="10" <?php selectedIf( 10, @$_REQUEST['maxDistance']) ?> >within 10 miles</option>
<option value="5" <?php selectedIf( 5, @$_REQUEST['maxDistance']) ?> >within 5 miles</option>
</select>

<input type="submit" value="Search" />
</form>


The action variable in the form tag will make the form submit to the page you enter in it.

Then list.php should just have the same content as sample_search.php.
Greg Thomas







PHP Programmer - interactivetools.com