Jump to content

Return Results From A Mysql Database Dependent On Town Entered


Recommended Posts

your text filed is missing a bunch of attributes, so is your form. try this:

<form name="townFilter" id="townFilter" method="post" action="viewall.php">
Town
<input type="text" name="townInput" value="" />
<input type="submit" name="townsearch" value="Search" />
</form>

 

This will let you access the $_POST superglobal array when you get to the viewall.php page.

superglobal arrays are special arrays in PHP, the main ones are $_POST, $_GET, $_SERVER and $_SESSION

$_POST and $_GET deal with form data (and url data in the case of $_GET) and are key to interacting with users through forms.

to access the arrays you need to do several things,

  • set the method that the form uses to send the data using method="post" / method="get"
  • name the form elements (you should really be doing this anyway as a best-practice)
  • set up some code on the target .php page to check for and use the form data when it gets there.

read up on $_POST at the php.net/manual site

If you can get the latitude and longitude of each place, or the OS easting and northing, then you can calculate the distances.

 

OS cordinates are easiest as they are in metres.

 

Otherwise if your displacements aren't too great (less than a few kilometers) and you're not right at the poles, use the quick and dirty estimate that 111,111 meters in the y direction is 1 degree (of latitude) and 111,111 * cos(latitude) meters in the x direction is 1 degree (of longitude).

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.